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 "include/rp_kernel.h"
22 #include "OpenCL/rp.c"
23 #include "OpenCL/simd.c"
25 __kernel void m04800_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)
31 const u32 lid = get_local_id (0);
37 const u32 gid = get_global_id (0);
39 if (gid >= gid_max) return;
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];
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];
55 const u32 pw_len = pws[gid].pw_len;
63 salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
64 salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
65 salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
66 salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
67 salt_buf[4] = salt_bufs[salt_pos].salt_buf[4];
69 const u32 salt_len = salt_bufs[salt_pos].salt_len;
75 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
82 const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
84 u32 pw_salt_len = out_len + salt_len;
118 switch_buffer_by_offset_le (s0, s1, s2, s3, out_len);
144 switch_buffer_by_offset_le (w0, w1, w2, w3, 1);
146 w0[0] |= salt_buf[4];
148 w3[2] = pw_salt_len * 8;
159 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
160 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
161 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
162 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
163 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
164 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
165 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
166 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
167 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
168 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
169 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
170 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
171 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
172 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
173 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
174 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
176 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
177 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
178 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
179 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
180 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
181 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
182 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
183 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
184 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
185 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
186 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
187 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
188 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
189 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
190 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
191 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
193 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
194 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
195 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
196 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
197 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
198 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
199 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
200 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
201 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
202 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
203 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
204 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
205 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
206 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
207 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
208 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
210 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
211 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
212 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
213 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
214 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
215 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
216 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
217 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
218 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
219 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
220 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
221 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
222 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
223 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
224 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
225 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
227 COMPARE_M_SIMD (a, d, c, b);
231 __kernel void m04800_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
235 __kernel void m04800_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
239 __kernel void m04800_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)
245 const u32 lid = get_local_id (0);
251 const u32 gid = get_global_id (0);
253 if (gid >= gid_max) return;
257 pw_buf0[0] = pws[gid].i[ 0];
258 pw_buf0[1] = pws[gid].i[ 1];
259 pw_buf0[2] = pws[gid].i[ 2];
260 pw_buf0[3] = pws[gid].i[ 3];
264 pw_buf1[0] = pws[gid].i[ 4];
265 pw_buf1[1] = pws[gid].i[ 5];
266 pw_buf1[2] = pws[gid].i[ 6];
267 pw_buf1[3] = pws[gid].i[ 7];
269 const u32 pw_len = pws[gid].pw_len;
277 salt_buf[0] = salt_bufs[salt_pos].salt_buf[0];
278 salt_buf[1] = salt_bufs[salt_pos].salt_buf[1];
279 salt_buf[2] = salt_bufs[salt_pos].salt_buf[2];
280 salt_buf[3] = salt_bufs[salt_pos].salt_buf[3];
281 salt_buf[4] = salt_bufs[salt_pos].salt_buf[4];
283 const u32 salt_len = salt_bufs[salt_pos].salt_len;
289 const u32 search[4] =
291 digests_buf[digests_offset].digest_buf[DGST_R0],
292 digests_buf[digests_offset].digest_buf[DGST_R1],
293 digests_buf[digests_offset].digest_buf[DGST_R2],
294 digests_buf[digests_offset].digest_buf[DGST_R3]
301 for (u32 il_pos = 0; il_pos < rules_cnt; il_pos += VECT_SIZE)
308 const u32 out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
310 u32 pw_salt_len = out_len + salt_len;
344 switch_buffer_by_offset_le (s0, s1, s2, s3, out_len);
370 switch_buffer_by_offset_le (w0, w1, w2, w3, 1);
372 w0[0] |= salt_buf[4];
374 w3[2] = pw_salt_len * 8;
385 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
386 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
387 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
388 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
389 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
390 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
391 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
392 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
393 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
394 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
395 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
396 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
397 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
398 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
399 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
400 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
402 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
403 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
404 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
405 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
406 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
407 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
408 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
409 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
410 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
411 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
412 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
413 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
414 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
415 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
416 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
417 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
419 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
420 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
421 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
422 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
423 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
424 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
425 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
426 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
427 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
428 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
429 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
430 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
431 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
432 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
433 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
434 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
436 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
437 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
438 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
439 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
440 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
441 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
442 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
443 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
444 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
445 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
446 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
447 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
448 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
450 if (MATCHES_NONE_VS (a, search[0])) continue;
452 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
453 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
454 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
456 COMPARE_S_SIMD (a, d, c, b);
460 __kernel void m04800_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
464 __kernel void m04800_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 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)