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