Test convert for -m 1000 with -a 0 for SIMD, speed is now on par or faster than hashcat
[hashcat.git] / OpenCL / m01000_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD4_
7
8 #define NEW_SIMD_CODE
9
10 #include "include/constants.h"
11 #include "include/kernel_vendor.h"
12
13 #define DGST_R0 0
14 #define DGST_R1 3
15 #define DGST_R2 2
16 #define DGST_R3 1
17
18 #include "include/kernel_functions.c"
19 #include "OpenCL/types_ocl.c"
20 #include "OpenCL/common.c"
21 #include "include/rp_kernel.h"
22 #include "OpenCL/rp.c"
23 #include "OpenCL/simd.c"
24
25 __kernel void m01000_m04 (__global pw_t *pws, __global kernel_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)
26 {
27   /**
28    * modifier
29    */
30
31   const u32 lid = get_local_id (0);
32
33   /**
34    * base
35    */
36
37   const u32 gid = get_global_id (0);
38
39   if (gid >= gid_max) return;
40
41   u32 pw_buf0[4];
42
43   pw_buf0[0] = pws[gid].i[ 0];
44   pw_buf0[1] = pws[gid].i[ 1];
45   pw_buf0[2] = pws[gid].i[ 2];
46   pw_buf0[3] = pws[gid].i[ 3];
47
48   u32 pw_buf1[4];
49
50   pw_buf1[0] = pws[gid].i[ 4];
51   pw_buf1[1] = pws[gid].i[ 5];
52   pw_buf1[2] = pws[gid].i[ 6];
53   pw_buf1[3] = pws[gid].i[ 7];
54
55   const u32 pw_len = pws[gid].pw_len;
56
57   /**
58    * loop
59    */
60
61   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
62   {
63     u32x w0[4] = { 0 };
64     u32x w1[4] = { 0 };
65     u32x w2[4] = { 0 };
66     u32x w3[4] = { 0 };
67
68     const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
69
70     append_0x80_2x4 (w0, w1, out_len);
71
72     u32x w0_t[4];
73     u32x w1_t[4];
74     u32x w2_t[4];
75     u32x w3_t[4];
76
77     make_unicode (w0, w0_t, w1_t);
78     make_unicode (w1, w2_t, w3_t);
79
80     w3_t[2] = out_len * 8 * 2;
81
82     u32x tmp2;
83
84     u32x a = MD4M_A;
85     u32x b = MD4M_B;
86     u32x c = MD4M_C;
87     u32x d = MD4M_D;
88
89     MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
90     MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
91     MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
92     MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
93     MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
94     MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
95     MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
96     MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
97     MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
98     MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
99     MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
100     MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
101     MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
102     MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
103     MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
104     MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
105
106     MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
107     MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
108     MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
109     MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
110     MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
111     MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
112     MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
113     MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
114     MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
115     MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
116     MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
117     MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
118     MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
119     MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
120     MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
121     MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
122
123     MD4_STEP (MD4_H1, a, b, c, d, w0_t[0], MD4C02, MD4S20);
124     MD4_STEP (MD4_H2, d, a, b, c, w2_t[0], MD4C02, MD4S21);
125     MD4_STEP (MD4_H1, c, d, a, b, w1_t[0], MD4C02, MD4S22);
126     MD4_STEP (MD4_H2, b, c, d, a, w3_t[0], MD4C02, MD4S23);
127     MD4_STEP (MD4_H1, a, b, c, d, w0_t[2], MD4C02, MD4S20);
128     MD4_STEP (MD4_H2, d, a, b, c, w2_t[2], MD4C02, MD4S21);
129     MD4_STEP (MD4_H1, c, d, a, b, w1_t[2], MD4C02, MD4S22);
130     MD4_STEP (MD4_H2, b, c, d, a, w3_t[2], MD4C02, MD4S23);
131     MD4_STEP (MD4_H1, a, b, c, d, w0_t[1], MD4C02, MD4S20);
132     MD4_STEP (MD4_H2, d, a, b, c, w2_t[1], MD4C02, MD4S21);
133     MD4_STEP (MD4_H1, c, d, a, b, w1_t[1], MD4C02, MD4S22);
134     MD4_STEP (MD4_H2, b, c, d, a, w3_t[1], MD4C02, MD4S23);
135     MD4_STEP (MD4_H1, a, b, c, d, w0_t[3], MD4C02, MD4S20);
136     MD4_STEP (MD4_H2, d, a, b, c, w2_t[3], MD4C02, MD4S21);
137     MD4_STEP (MD4_H1, c, d, a, b, w1_t[3], MD4C02, MD4S22);
138     MD4_STEP (MD4_H2, b, c, d, a, w3_t[3], MD4C02, MD4S23);
139
140     COMPARE_M_SIMD (a, d, c, b);
141   }
142 }
143
144 __kernel void m01000_m08 (__global pw_t *pws, __global kernel_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)
145 {
146 }
147
148 __kernel void m01000_m16 (__global pw_t *pws, __global kernel_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)
149 {
150 }
151
152 __kernel void m01000_s04 (__global pw_t *pws, __global kernel_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)
153 {
154   /**
155    * modifier
156    */
157
158   const u32 lid = get_local_id (0);
159
160   /**
161    * base
162    */
163
164   const u32 gid = get_global_id (0);
165
166   if (gid >= gid_max) return;
167
168   u32 pw_buf0[4];
169
170   pw_buf0[0] = pws[gid].i[ 0];
171   pw_buf0[1] = pws[gid].i[ 1];
172   pw_buf0[2] = pws[gid].i[ 2];
173   pw_buf0[3] = pws[gid].i[ 3];
174
175   u32 pw_buf1[4];
176
177   pw_buf1[0] = pws[gid].i[ 4];
178   pw_buf1[1] = pws[gid].i[ 5];
179   pw_buf1[2] = pws[gid].i[ 6];
180   pw_buf1[3] = pws[gid].i[ 7];
181
182   const u32 pw_len = pws[gid].pw_len;
183
184   /**
185    * digest
186    */
187
188   const u32 search[4] =
189   {
190     digests_buf[digests_offset].digest_buf[DGST_R0],
191     digests_buf[digests_offset].digest_buf[DGST_R1],
192     digests_buf[digests_offset].digest_buf[DGST_R2],
193     digests_buf[digests_offset].digest_buf[DGST_R3]
194   };
195
196   /**
197    * loop
198    */
199
200   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
201   {
202     u32x w0[4] = { 0 };
203     u32x w1[4] = { 0 };
204     u32x w2[4] = { 0 };
205     u32x w3[4] = { 0 };
206
207     const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
208
209     append_0x80_2x4 (w0, w1, out_len);
210
211     u32x w0_t[4];
212     u32x w1_t[4];
213     u32x w2_t[4];
214     u32x w3_t[4];
215
216     make_unicode (w0, w0_t, w1_t);
217     make_unicode (w1, w2_t, w3_t);
218
219     w3_t[2] = out_len * 8 * 2;
220
221     u32x tmp2;
222
223     u32x a = MD4M_A;
224     u32x b = MD4M_B;
225     u32x c = MD4M_C;
226     u32x d = MD4M_D;
227
228     MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
229     MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
230     MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
231     MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
232     MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
233     MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
234     MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
235     MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
236     MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
237     MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
238     MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
239     MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
240     MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
241     MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
242     MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
243     MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
244
245     MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
246     MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
247     MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
248     MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
249     MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
250     MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
251     MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
252     MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
253     MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
254     MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
255     MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
256     MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
257     MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
258     MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
259     MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
260     MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
261
262     MD4_STEP (MD4_H1, a, b, c, d, w0_t[0], MD4C02, MD4S20);
263     MD4_STEP (MD4_H2, d, a, b, c, w2_t[0], MD4C02, MD4S21);
264     MD4_STEP (MD4_H1, c, d, a, b, w1_t[0], MD4C02, MD4S22);
265     MD4_STEP (MD4_H2, b, c, d, a, w3_t[0], MD4C02, MD4S23);
266     MD4_STEP (MD4_H1, a, b, c, d, w0_t[2], MD4C02, MD4S20);
267     MD4_STEP (MD4_H2, d, a, b, c, w2_t[2], MD4C02, MD4S21);
268     MD4_STEP (MD4_H1, c, d, a, b, w1_t[2], MD4C02, MD4S22);
269     MD4_STEP (MD4_H2, b, c, d, a, w3_t[2], MD4C02, MD4S23);
270     MD4_STEP (MD4_H1, a, b, c, d, w0_t[1], MD4C02, MD4S20);
271     MD4_STEP (MD4_H2, d, a, b, c, w2_t[1], MD4C02, MD4S21);
272     MD4_STEP (MD4_H1, c, d, a, b, w1_t[1], MD4C02, MD4S22);
273     MD4_STEP (MD4_H2, b, c, d, a, w3_t[1], MD4C02, MD4S23);
274     MD4_STEP (MD4_H1, a, b, c, d, w0_t[3], MD4C02, MD4S20);
275
276     if (MATCHES_NONE_VS (a, search[0])) continue;
277
278     MD4_STEP (MD4_H2, d, a, b, c, w2_t[3], MD4C02, MD4S21);
279     MD4_STEP (MD4_H1, c, d, a, b, w1_t[3], MD4C02, MD4S22);
280     MD4_STEP (MD4_H2, b, c, d, a, w3_t[3], MD4C02, MD4S23);
281
282     COMPARE_S_SIMD (a, d, c, b);
283   }
284 }
285
286 __kernel void m01000_s08 (__global pw_t *pws, __global kernel_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)
287 {
288 }
289
290 __kernel void m01000_s16 (__global pw_t *pws, __global kernel_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)
291 {
292 }