Initial commit
[hashcat.git] / amd / m00900_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))) m00900_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     w3[2] = out_len * 8;
120
121     u32x a = MD4M_A;
122     u32x b = MD4M_B;
123     u32x c = MD4M_C;
124     u32x d = MD4M_D;
125
126     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
127     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
128     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
129     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
130     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
131     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
132     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
133     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
134     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
135     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
136     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
137     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
138     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
139     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
140     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
141     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
142
143     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
144     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
145     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
146     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
147     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
148     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
149     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
150     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
151     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
152     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
153     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
154     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
155     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
156     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
157     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
158     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
159
160     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
161     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
162     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
163     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
164     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
165     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
166     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
167     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
168     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
169     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
170     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
171     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
172     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
173     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
174     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
175     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
176
177     const u32x r0 = a;
178     const u32x r1 = d;
179     const u32x r2 = c;
180     const u32x r3 = b;
181
182     #include VECT_COMPARE_M
183   }
184 }
185
186 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00900_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)
187 {
188 }
189
190 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00900_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)
191 {
192 }
193
194 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00900_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)
195 {
196   /**
197    * modifier
198    */
199
200   const u32 lid = get_local_id (0);
201
202   /**
203    * base
204    */
205
206   const u32 gid = get_global_id (0);
207
208   if (gid >= gid_max) return;
209
210   u32x pw_buf0[4];
211
212   pw_buf0[0] = pws[gid].i[ 0];
213   pw_buf0[1] = pws[gid].i[ 1];
214   pw_buf0[2] = pws[gid].i[ 2];
215   pw_buf0[3] = pws[gid].i[ 3];
216
217   u32x pw_buf1[4];
218
219   pw_buf1[0] = pws[gid].i[ 4];
220   pw_buf1[1] = pws[gid].i[ 5];
221   pw_buf1[2] = pws[gid].i[ 6];
222   pw_buf1[3] = pws[gid].i[ 7];
223
224   const u32 pw_len = pws[gid].pw_len;
225
226   /**
227    * digest
228    */
229
230   const u32 search[4] =
231   {
232     digests_buf[digests_offset].digest_buf[DGST_R0],
233     digests_buf[digests_offset].digest_buf[DGST_R1],
234     digests_buf[digests_offset].digest_buf[DGST_R2],
235     digests_buf[digests_offset].digest_buf[DGST_R3]
236   };
237
238   /**
239    * loop
240    */
241
242   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
243   {
244     u32x w0[4];
245
246     w0[0] = pw_buf0[0];
247     w0[1] = pw_buf0[1];
248     w0[2] = pw_buf0[2];
249     w0[3] = pw_buf0[3];
250
251     u32x w1[4];
252
253     w1[0] = pw_buf1[0];
254     w1[1] = pw_buf1[1];
255     w1[2] = pw_buf1[2];
256     w1[3] = pw_buf1[3];
257
258     u32x w2[4];
259
260     w2[0] = 0;
261     w2[1] = 0;
262     w2[2] = 0;
263     w2[3] = 0;
264
265     u32x w3[4];
266
267     w3[0] = 0;
268     w3[1] = 0;
269     w3[2] = 0;
270     w3[3] = 0;
271
272     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
273
274     append_0x80_2 (w0, w1, out_len);
275
276     w3[2] = out_len * 8;
277
278     u32x a = MD4M_A;
279     u32x b = MD4M_B;
280     u32x c = MD4M_C;
281     u32x d = MD4M_D;
282
283     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
284     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
285     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
286     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
287     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
288     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
289     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
290     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
291     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
292     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
293     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
294     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
295     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
296     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
297     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
298     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
299
300     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
301     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
302     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
303     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
304     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
305     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
306     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
307     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
308     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
309     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
310     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
311     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
312     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
313     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
314     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
315     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
316
317     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
318     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
319     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
320     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
321     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
322     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
323     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
324     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
325     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
326     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
327     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
328     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
329     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
330     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
331     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
332     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
333
334     const u32x r0 = a;
335     const u32x r1 = d;
336     const u32x r2 = c;
337     const u32x r3 = b;
338
339     #include VECT_COMPARE_S
340   }
341 }
342
343 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00900_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)
344 {
345 }
346
347 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00900_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)
348 {
349 }