2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "include/constants.h"
11 #include "include/kernel_vendor.h"
18 #include "include/kernel_functions.c"
19 #include "OpenCL/types_ocl.c"
20 #include "OpenCL/common.c"
21 #include "OpenCL/simd.c"
23 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
29 const u32 lid = get_local_id (0);
35 const u32 gid = get_global_id (0);
37 if (gid >= gid_max) return;
42 pws0[0] = pws[gid].i[0];
43 pws0[1] = pws[gid].i[1];
44 pws0[2] = pws[gid].i[2];
45 pws0[3] = pws[gid].i[3];
46 pws1[0] = pws[gid].i[4];
47 pws1[1] = pws[gid].i[5];
48 pws1[2] = pws[gid].i[6];
49 pws1[3] = pws[gid].i[7];
51 const u32 pw_l_len = pws[gid].pw_len;
57 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
59 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
61 const u32x pw_len = pw_l_len + pw_r_len;
63 u32x wordr0[4] = { 0 };
64 u32x wordr1[4] = { 0 };
65 u32x wordr2[4] = { 0 };
66 u32x wordr3[4] = { 0 };
68 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
69 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
70 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
71 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
72 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
73 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
74 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
75 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
77 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
79 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
84 w0[0] = wordl0[0] | wordr0[0];
85 w0[1] = wordl0[1] | wordr0[1];
86 w0[2] = wordl0[2] | wordr0[2];
87 w0[3] = wordl0[3] | wordr0[3];
91 w1[0] = wordl1[0] | wordr1[0];
92 w1[1] = wordl1[1] | wordr1[1];
93 w1[2] = wordl1[2] | wordr1[2];
94 w1[3] = wordl1[3] | wordr1[3];
115 make_unicode (w0, w0_t, w1_t);
116 make_unicode (w1, w2_t, w3_t);
118 w3_t[2] = pw_len * 8 * 2;
125 MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
126 MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
127 MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
128 MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
129 MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
130 MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
131 MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
132 MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
133 MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
134 MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
135 MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
136 MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
137 MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
138 MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
139 MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
140 MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
142 MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
143 MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
144 MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
145 MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
146 MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
147 MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
148 MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
149 MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
150 MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
151 MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
152 MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
153 MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
154 MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
155 MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
156 MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
157 MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
159 MD4_STEP (MD4_H , a, b, c, d, w0_t[0], MD4C02, MD4S20);
160 MD4_STEP (MD4_H , d, a, b, c, w2_t[0], MD4C02, MD4S21);
161 MD4_STEP (MD4_H , c, d, a, b, w1_t[0], MD4C02, MD4S22);
162 MD4_STEP (MD4_H , b, c, d, a, w3_t[0], MD4C02, MD4S23);
163 MD4_STEP (MD4_H , a, b, c, d, w0_t[2], MD4C02, MD4S20);
164 MD4_STEP (MD4_H , d, a, b, c, w2_t[2], MD4C02, MD4S21);
165 MD4_STEP (MD4_H , c, d, a, b, w1_t[2], MD4C02, MD4S22);
166 MD4_STEP (MD4_H , b, c, d, a, w3_t[2], MD4C02, MD4S23);
167 MD4_STEP (MD4_H , a, b, c, d, w0_t[1], MD4C02, MD4S20);
168 MD4_STEP (MD4_H , d, a, b, c, w2_t[1], MD4C02, MD4S21);
169 MD4_STEP (MD4_H , c, d, a, b, w1_t[1], MD4C02, MD4S22);
170 MD4_STEP (MD4_H , b, c, d, a, w3_t[1], MD4C02, MD4S23);
171 MD4_STEP (MD4_H , a, b, c, d, w0_t[3], MD4C02, MD4S20);
172 MD4_STEP (MD4_H , d, a, b, c, w2_t[3], MD4C02, MD4S21);
173 MD4_STEP (MD4_H , c, d, a, b, w1_t[3], MD4C02, MD4S22);
174 MD4_STEP (MD4_H , b, c, d, a, w3_t[3], MD4C02, MD4S23);
175 COMPARE_M_SIMD (a, d, c, b);
179 __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)
183 __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)
187 __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 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
193 const u32 lid = get_local_id (0);
199 const u32 gid = get_global_id (0);
201 if (gid >= gid_max) return;
206 pws0[0] = pws[gid].i[0];
207 pws0[1] = pws[gid].i[1];
208 pws0[2] = pws[gid].i[2];
209 pws0[3] = pws[gid].i[3];
210 pws1[0] = pws[gid].i[4];
211 pws1[1] = pws[gid].i[5];
212 pws1[2] = pws[gid].i[6];
213 pws1[3] = pws[gid].i[7];
215 const u32 pw_l_len = pws[gid].pw_len;
221 const u32 search[4] =
223 digests_buf[digests_offset].digest_buf[DGST_R0],
224 digests_buf[digests_offset].digest_buf[DGST_R1],
225 digests_buf[digests_offset].digest_buf[DGST_R2],
226 digests_buf[digests_offset].digest_buf[DGST_R3]
233 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
235 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
237 const u32x pw_len = pw_l_len + pw_r_len;
239 u32x wordr0[4] = { 0 };
240 u32x wordr1[4] = { 0 };
241 u32x wordr2[4] = { 0 };
242 u32x wordr3[4] = { 0 };
244 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
245 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
246 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
247 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
248 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
249 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
250 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
251 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
253 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
255 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
260 w0[0] = wordl0[0] | wordr0[0];
261 w0[1] = wordl0[1] | wordr0[1];
262 w0[2] = wordl0[2] | wordr0[2];
263 w0[3] = wordl0[3] | wordr0[3];
267 w1[0] = wordl1[0] | wordr1[0];
268 w1[1] = wordl1[1] | wordr1[1];
269 w1[2] = wordl1[2] | wordr1[2];
270 w1[3] = wordl1[3] | wordr1[3];
291 make_unicode (w0, w0_t, w1_t);
292 make_unicode (w1, w2_t, w3_t);
294 w3_t[2] = pw_len * 8 * 2;
301 MD4_STEP (MD4_Fo, a, b, c, d, w0_t[0], MD4C00, MD4S00);
302 MD4_STEP (MD4_Fo, d, a, b, c, w0_t[1], MD4C00, MD4S01);
303 MD4_STEP (MD4_Fo, c, d, a, b, w0_t[2], MD4C00, MD4S02);
304 MD4_STEP (MD4_Fo, b, c, d, a, w0_t[3], MD4C00, MD4S03);
305 MD4_STEP (MD4_Fo, a, b, c, d, w1_t[0], MD4C00, MD4S00);
306 MD4_STEP (MD4_Fo, d, a, b, c, w1_t[1], MD4C00, MD4S01);
307 MD4_STEP (MD4_Fo, c, d, a, b, w1_t[2], MD4C00, MD4S02);
308 MD4_STEP (MD4_Fo, b, c, d, a, w1_t[3], MD4C00, MD4S03);
309 MD4_STEP (MD4_Fo, a, b, c, d, w2_t[0], MD4C00, MD4S00);
310 MD4_STEP (MD4_Fo, d, a, b, c, w2_t[1], MD4C00, MD4S01);
311 MD4_STEP (MD4_Fo, c, d, a, b, w2_t[2], MD4C00, MD4S02);
312 MD4_STEP (MD4_Fo, b, c, d, a, w2_t[3], MD4C00, MD4S03);
313 MD4_STEP (MD4_Fo, a, b, c, d, w3_t[0], MD4C00, MD4S00);
314 MD4_STEP (MD4_Fo, d, a, b, c, w3_t[1], MD4C00, MD4S01);
315 MD4_STEP (MD4_Fo, c, d, a, b, w3_t[2], MD4C00, MD4S02);
316 MD4_STEP (MD4_Fo, b, c, d, a, w3_t[3], MD4C00, MD4S03);
318 MD4_STEP (MD4_Go, a, b, c, d, w0_t[0], MD4C01, MD4S10);
319 MD4_STEP (MD4_Go, d, a, b, c, w1_t[0], MD4C01, MD4S11);
320 MD4_STEP (MD4_Go, c, d, a, b, w2_t[0], MD4C01, MD4S12);
321 MD4_STEP (MD4_Go, b, c, d, a, w3_t[0], MD4C01, MD4S13);
322 MD4_STEP (MD4_Go, a, b, c, d, w0_t[1], MD4C01, MD4S10);
323 MD4_STEP (MD4_Go, d, a, b, c, w1_t[1], MD4C01, MD4S11);
324 MD4_STEP (MD4_Go, c, d, a, b, w2_t[1], MD4C01, MD4S12);
325 MD4_STEP (MD4_Go, b, c, d, a, w3_t[1], MD4C01, MD4S13);
326 MD4_STEP (MD4_Go, a, b, c, d, w0_t[2], MD4C01, MD4S10);
327 MD4_STEP (MD4_Go, d, a, b, c, w1_t[2], MD4C01, MD4S11);
328 MD4_STEP (MD4_Go, c, d, a, b, w2_t[2], MD4C01, MD4S12);
329 MD4_STEP (MD4_Go, b, c, d, a, w3_t[2], MD4C01, MD4S13);
330 MD4_STEP (MD4_Go, a, b, c, d, w0_t[3], MD4C01, MD4S10);
331 MD4_STEP (MD4_Go, d, a, b, c, w1_t[3], MD4C01, MD4S11);
332 MD4_STEP (MD4_Go, c, d, a, b, w2_t[3], MD4C01, MD4S12);
333 MD4_STEP (MD4_Go, b, c, d, a, w3_t[3], MD4C01, MD4S13);
335 MD4_STEP (MD4_H , a, b, c, d, w0_t[0], MD4C02, MD4S20);
336 MD4_STEP (MD4_H , d, a, b, c, w2_t[0], MD4C02, MD4S21);
337 MD4_STEP (MD4_H , c, d, a, b, w1_t[0], MD4C02, MD4S22);
338 MD4_STEP (MD4_H , b, c, d, a, w3_t[0], MD4C02, MD4S23);
339 MD4_STEP (MD4_H , a, b, c, d, w0_t[2], MD4C02, MD4S20);
340 MD4_STEP (MD4_H , d, a, b, c, w2_t[2], MD4C02, MD4S21);
341 MD4_STEP (MD4_H , c, d, a, b, w1_t[2], MD4C02, MD4S22);
342 MD4_STEP (MD4_H , b, c, d, a, w3_t[2], MD4C02, MD4S23);
343 MD4_STEP (MD4_H , a, b, c, d, w0_t[1], MD4C02, MD4S20);
344 MD4_STEP (MD4_H , d, a, b, c, w2_t[1], MD4C02, MD4S21);
345 MD4_STEP (MD4_H , c, d, a, b, w1_t[1], MD4C02, MD4S22);
346 MD4_STEP (MD4_H , b, c, d, a, w3_t[1], MD4C02, MD4S23);
347 MD4_STEP (MD4_H , a, b, c, d, w0_t[3], MD4C02, MD4S20);
348 MD4_STEP (MD4_H , d, a, b, c, w2_t[3], MD4C02, MD4S21);
349 MD4_STEP (MD4_H , c, d, a, b, w1_t[3], MD4C02, MD4S22);
350 MD4_STEP (MD4_H , b, c, d, a, w3_t[3], MD4C02, MD4S23);
351 COMPARE_S_SIMD (a, d, c, b);
355 __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)
359 __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)