1355f1584f01e567c495f88a3a29ea821957acdc
[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 "inc_hash_constants.h"
11 #include "inc_vendor.cl"
12
13 #define DGST_R0 0
14 #define DGST_R1 3
15 #define DGST_R2 2
16 #define DGST_R3 1
17
18 #include "inc_hash_functions.cl"
19 #include "inc_types.cl"
20 #include "inc_common.cl"
21 #include "inc_rp.h"
22 #include "inc_rp.cl"
23 #include "inc_simd.cl"
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 il_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   u32 pw_buf1[4];
43
44   pw_buf0[0] = pws[gid].i[0];
45   pw_buf0[1] = pws[gid].i[1];
46   pw_buf0[2] = pws[gid].i[2];
47   pw_buf0[3] = pws[gid].i[3];
48   pw_buf1[0] = pws[gid].i[4];
49   pw_buf1[1] = pws[gid].i[5];
50   pw_buf1[2] = pws[gid].i[6];
51   pw_buf1[3] = pws[gid].i[7];
52
53   const u32 pw_len = pws[gid].pw_len;
54
55   /**
56    * loop
57    */
58
59   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
60   {
61     u32x w0[4] = { 0 };
62     u32x w1[4] = { 0 };
63     u32x w2[4] = { 0 };
64     u32x w3[4] = { 0 };
65
66     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
67
68     append_0x80_2x4_VV (w0, w1, out_len);
69
70     make_unicode (w1, w2, w3);
71     make_unicode (w0, w0, w1);
72
73     w3[2] = out_len * 8 * 2;
74     w3[3] = 0;
75
76     u32x a = MD4M_A;
77     u32x b = MD4M_B;
78     u32x c = MD4M_C;
79     u32x d = MD4M_D;
80
81     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
82     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
83     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
84     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
85     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
86     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
87     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
88     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
89     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
90     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
91     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
92     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
93     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
94     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
95     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
96     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
97
98     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
99     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
100     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
101     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
102     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
103     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
104     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
105     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
106     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
107     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
108     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
109     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
110     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
111     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
112     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
113     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
114
115     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
116     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
117     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
118     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
119     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
120     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
121     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
122     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
123     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
124     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
125     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
126     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
127     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
128     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
129     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
130     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
131
132     COMPARE_M_SIMD (a, d, c, b);
133   }
134 }
135
136 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
137 {
138 }
139
140 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
141 {
142 }
143
144 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
145 {
146   /**
147    * modifier
148    */
149
150   const u32 lid = get_local_id (0);
151
152   /**
153    * base
154    */
155
156   const u32 gid = get_global_id (0);
157
158   if (gid >= gid_max) return;
159
160   u32 pw_buf0[4];
161   u32 pw_buf1[4];
162
163   pw_buf0[0] = pws[gid].i[0];
164   pw_buf0[1] = pws[gid].i[1];
165   pw_buf0[2] = pws[gid].i[2];
166   pw_buf0[3] = pws[gid].i[3];
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 < il_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 u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
198
199     append_0x80_2x4_VV (w0, w1, out_len);
200
201     make_unicode (w1, w2, w3);
202     make_unicode (w0, w0, w1);
203
204     w3[2] = out_len * 8 * 2;
205     w3[3] = 0;
206
207     u32x a = MD4M_A;
208     u32x b = MD4M_B;
209     u32x c = MD4M_C;
210     u32x d = MD4M_D;
211
212     MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
213     MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
214     MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
215     MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
216     MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
217     MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
218     MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
219     MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
220     MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
221     MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
222     MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
223     MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
224     MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
225     MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
226     MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
227     MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
228
229     MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
230     MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
231     MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
232     MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
233     MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
234     MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
235     MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
236     MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
237     MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
238     MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
239     MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
240     MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
241     MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
242     MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
243     MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
244     MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
245
246     MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
247     MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
248     MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
249     MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
250     MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
251     MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
252     MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
253     MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
254     MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
255     MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
256     MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
257     MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
258     MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
259
260     if (MATCHES_NONE_VS (a, search[0])) continue;
261
262     MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
263     MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
264     MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
265
266     COMPARE_S_SIMD (a, d, c, b);
267   }
268 }
269
270 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
271 {
272 }
273
274 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
275 {
276 }