Converted to new SIMD: -m 900 -a 0
[hashcat.git] / OpenCL / m00900_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 m00900_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     w3[2] = out_len * 8;
73
74     u32x a = MD4M_A;
75     u32x b = MD4M_B;
76     u32x c = MD4M_C;
77     u32x d = MD4M_D;
78
79     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
80     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
81     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
82     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
83     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
84     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
85     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
86     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
87     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
88     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
89     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
90     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
91     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
92     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
93     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
94     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
95
96     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
97     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
98     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
99     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
100     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
101     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
102     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
103     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
104     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
105     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
106     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
107     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
108     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
109     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
110     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
111     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
112
113     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
114     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
115     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
116     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
117     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
118     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
119     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
120     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
121     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
122     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
123     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
124     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
125     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
126     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
127     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
128     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
129
130     COMPARE_M_SIMD (a, d, c, b);
131   }
132 }
133
134 __kernel void m00900_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)
135 {
136 }
137
138 __kernel void m00900_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)
139 {
140 }
141
142 __kernel void m00900_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)
143 {
144   /**
145    * modifier
146    */
147
148   const u32 lid = get_local_id (0);
149
150   /**
151    * base
152    */
153
154   const u32 gid = get_global_id (0);
155
156   if (gid >= gid_max) return;
157
158   u32 pw_buf0[4];
159
160   pw_buf0[0] = pws[gid].i[ 0];
161   pw_buf0[1] = pws[gid].i[ 1];
162   pw_buf0[2] = pws[gid].i[ 2];
163   pw_buf0[3] = pws[gid].i[ 3];
164
165   u32 pw_buf1[4];
166
167   pw_buf1[0] = pws[gid].i[ 4];
168   pw_buf1[1] = pws[gid].i[ 5];
169   pw_buf1[2] = pws[gid].i[ 6];
170   pw_buf1[3] = pws[gid].i[ 7];
171
172   const u32 pw_len = pws[gid].pw_len;
173
174   /**
175    * digest
176    */
177
178   const u32 search[4] =
179   {
180     digests_buf[digests_offset].digest_buf[DGST_R0],
181     digests_buf[digests_offset].digest_buf[DGST_R1],
182     digests_buf[digests_offset].digest_buf[DGST_R2],
183     digests_buf[digests_offset].digest_buf[DGST_R3]
184   };
185
186   /**
187    * loop
188    */
189
190   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
191   {
192     u32x w0[4] = { 0 };
193     u32x w1[4] = { 0 };
194     u32x w2[4] = { 0 };
195     u32x w3[4] = { 0 };
196
197     const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
198
199     append_0x80_2x4 (w0, w1, out_len);
200
201     w3[2] = out_len * 8;
202
203     u32x a = MD4M_A;
204     u32x b = MD4M_B;
205     u32x c = MD4M_C;
206     u32x d = MD4M_D;
207
208     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
209     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
210     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
211     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
212     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
213     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
214     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
215     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
216     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
217     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
218     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
219     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
220     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
221     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
222     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
223     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
224
225     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
226     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
227     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
228     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
229     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
230     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
231     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
232     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
233     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
234     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
235     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
236     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
237     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
238     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
239     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
240     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
241
242     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
243     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
244     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
245     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
246     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
247     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
248     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
249     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
250     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
251     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
252     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
253     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
254     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
255
256     if (MATCHES_NONE_VS (a, search[0])) continue;
257
258     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
259     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
260     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
261
262     COMPARE_M_SIMD (a, d, c, b);
263   }
264 }
265
266 __kernel void m00900_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)
267 {
268 }
269
270 __kernel void m00900_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)
271 {
272 }