2 * Author......: Jens Steube <jens.steube@gmail.com>
10 #include "inc_hash_constants.h"
11 #include "inc_vendor.cl"
18 #include "inc_hash_functions.cl"
19 #include "inc_types.cl"
20 #include "inc_common.cl"
21 #include "inc_simd.cl"
23 __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 il_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 pw_buf0[0] = pws[gid].i[0];
43 pw_buf0[1] = pws[gid].i[1];
44 pw_buf0[2] = pws[gid].i[2];
45 pw_buf0[3] = pws[gid].i[3];
46 pw_buf1[0] = pws[gid].i[4];
47 pw_buf1[1] = pws[gid].i[5];
48 pw_buf1[2] = pws[gid].i[6];
49 pw_buf1[3] = pws[gid].i[7];
51 const u32 pw_l_len = pws[gid].pw_len;
57 for (u32 il_pos = 0; il_pos < il_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;
64 * concat password candidate
67 u32x wordl0[4] = { 0 };
68 u32x wordl1[4] = { 0 };
69 u32x wordl2[4] = { 0 };
70 u32x wordl3[4] = { 0 };
72 wordl0[0] = pw_buf0[0];
73 wordl0[1] = pw_buf0[1];
74 wordl0[2] = pw_buf0[2];
75 wordl0[3] = pw_buf0[3];
76 wordl1[0] = pw_buf1[0];
77 wordl1[1] = pw_buf1[1];
78 wordl1[2] = pw_buf1[2];
79 wordl1[3] = pw_buf1[3];
81 u32x wordr0[4] = { 0 };
82 u32x wordr1[4] = { 0 };
83 u32x wordr2[4] = { 0 };
84 u32x wordr3[4] = { 0 };
86 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
87 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
88 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
89 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
90 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
91 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
92 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
93 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
95 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
97 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
101 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
109 w0[0] = wordl0[0] | wordr0[0];
110 w0[1] = wordl0[1] | wordr0[1];
111 w0[2] = wordl0[2] | wordr0[2];
112 w0[3] = wordl0[3] | wordr0[3];
113 w1[0] = wordl1[0] | wordr1[0];
114 w1[1] = wordl1[1] | wordr1[1];
115 w1[2] = wordl1[2] | wordr1[2];
116 w1[3] = wordl1[3] | wordr1[3];
117 w2[0] = wordl2[0] | wordr2[0];
118 w2[1] = wordl2[1] | wordr2[1];
119 w2[2] = wordl2[2] | wordr2[2];
120 w2[3] = wordl2[3] | wordr2[3];
121 w3[0] = wordl3[0] | wordr3[0];
122 w3[1] = wordl3[1] | wordr3[1];
135 MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
136 MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
137 MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
138 MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
139 MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
140 MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
141 MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
142 MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
143 MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
144 MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
145 MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
146 MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
147 MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
148 MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
149 MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
150 MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
152 MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
153 MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
154 MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
155 MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
156 MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
157 MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
158 MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
159 MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
160 MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
161 MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
162 MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
163 MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
164 MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
165 MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
166 MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
167 MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
169 MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
170 MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
171 MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
172 MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
173 MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
174 MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
175 MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
176 MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
177 MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
178 MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
179 MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
180 MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
181 MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
182 MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
183 MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
184 MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
186 COMPARE_M_SIMD (a, d, c, b);
190 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
194 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
198 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
204 const u32 lid = get_local_id (0);
210 const u32 gid = get_global_id (0);
212 if (gid >= gid_max) return;
217 pw_buf0[0] = pws[gid].i[0];
218 pw_buf0[1] = pws[gid].i[1];
219 pw_buf0[2] = pws[gid].i[2];
220 pw_buf0[3] = pws[gid].i[3];
221 pw_buf1[0] = pws[gid].i[4];
222 pw_buf1[1] = pws[gid].i[5];
223 pw_buf1[2] = pws[gid].i[6];
224 pw_buf1[3] = pws[gid].i[7];
226 const u32 pw_l_len = pws[gid].pw_len;
232 const u32 search[4] =
234 digests_buf[digests_offset].digest_buf[DGST_R0],
235 digests_buf[digests_offset].digest_buf[DGST_R1],
236 digests_buf[digests_offset].digest_buf[DGST_R2],
237 digests_buf[digests_offset].digest_buf[DGST_R3]
244 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
246 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
248 const u32x pw_len = pw_l_len + pw_r_len;
251 * concat password candidate
254 u32x wordl0[4] = { 0 };
255 u32x wordl1[4] = { 0 };
256 u32x wordl2[4] = { 0 };
257 u32x wordl3[4] = { 0 };
259 wordl0[0] = pw_buf0[0];
260 wordl0[1] = pw_buf0[1];
261 wordl0[2] = pw_buf0[2];
262 wordl0[3] = pw_buf0[3];
263 wordl1[0] = pw_buf1[0];
264 wordl1[1] = pw_buf1[1];
265 wordl1[2] = pw_buf1[2];
266 wordl1[3] = pw_buf1[3];
268 u32x wordr0[4] = { 0 };
269 u32x wordr1[4] = { 0 };
270 u32x wordr2[4] = { 0 };
271 u32x wordr3[4] = { 0 };
273 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
274 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
275 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
276 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
277 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
278 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
279 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
280 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
282 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
284 switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
288 switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
296 w0[0] = wordl0[0] | wordr0[0];
297 w0[1] = wordl0[1] | wordr0[1];
298 w0[2] = wordl0[2] | wordr0[2];
299 w0[3] = wordl0[3] | wordr0[3];
300 w1[0] = wordl1[0] | wordr1[0];
301 w1[1] = wordl1[1] | wordr1[1];
302 w1[2] = wordl1[2] | wordr1[2];
303 w1[3] = wordl1[3] | wordr1[3];
304 w2[0] = wordl2[0] | wordr2[0];
305 w2[1] = wordl2[1] | wordr2[1];
306 w2[2] = wordl2[2] | wordr2[2];
307 w2[3] = wordl2[3] | wordr2[3];
308 w3[0] = wordl3[0] | wordr3[0];
309 w3[1] = wordl3[1] | wordr3[1];
322 MD4_STEP (MD4_Fo, a, b, c, d, w0[0], MD4C00, MD4S00);
323 MD4_STEP (MD4_Fo, d, a, b, c, w0[1], MD4C00, MD4S01);
324 MD4_STEP (MD4_Fo, c, d, a, b, w0[2], MD4C00, MD4S02);
325 MD4_STEP (MD4_Fo, b, c, d, a, w0[3], MD4C00, MD4S03);
326 MD4_STEP (MD4_Fo, a, b, c, d, w1[0], MD4C00, MD4S00);
327 MD4_STEP (MD4_Fo, d, a, b, c, w1[1], MD4C00, MD4S01);
328 MD4_STEP (MD4_Fo, c, d, a, b, w1[2], MD4C00, MD4S02);
329 MD4_STEP (MD4_Fo, b, c, d, a, w1[3], MD4C00, MD4S03);
330 MD4_STEP (MD4_Fo, a, b, c, d, w2[0], MD4C00, MD4S00);
331 MD4_STEP (MD4_Fo, d, a, b, c, w2[1], MD4C00, MD4S01);
332 MD4_STEP (MD4_Fo, c, d, a, b, w2[2], MD4C00, MD4S02);
333 MD4_STEP (MD4_Fo, b, c, d, a, w2[3], MD4C00, MD4S03);
334 MD4_STEP (MD4_Fo, a, b, c, d, w3[0], MD4C00, MD4S00);
335 MD4_STEP (MD4_Fo, d, a, b, c, w3[1], MD4C00, MD4S01);
336 MD4_STEP (MD4_Fo, c, d, a, b, w3[2], MD4C00, MD4S02);
337 MD4_STEP (MD4_Fo, b, c, d, a, w3[3], MD4C00, MD4S03);
339 MD4_STEP (MD4_Go, a, b, c, d, w0[0], MD4C01, MD4S10);
340 MD4_STEP (MD4_Go, d, a, b, c, w1[0], MD4C01, MD4S11);
341 MD4_STEP (MD4_Go, c, d, a, b, w2[0], MD4C01, MD4S12);
342 MD4_STEP (MD4_Go, b, c, d, a, w3[0], MD4C01, MD4S13);
343 MD4_STEP (MD4_Go, a, b, c, d, w0[1], MD4C01, MD4S10);
344 MD4_STEP (MD4_Go, d, a, b, c, w1[1], MD4C01, MD4S11);
345 MD4_STEP (MD4_Go, c, d, a, b, w2[1], MD4C01, MD4S12);
346 MD4_STEP (MD4_Go, b, c, d, a, w3[1], MD4C01, MD4S13);
347 MD4_STEP (MD4_Go, a, b, c, d, w0[2], MD4C01, MD4S10);
348 MD4_STEP (MD4_Go, d, a, b, c, w1[2], MD4C01, MD4S11);
349 MD4_STEP (MD4_Go, c, d, a, b, w2[2], MD4C01, MD4S12);
350 MD4_STEP (MD4_Go, b, c, d, a, w3[2], MD4C01, MD4S13);
351 MD4_STEP (MD4_Go, a, b, c, d, w0[3], MD4C01, MD4S10);
352 MD4_STEP (MD4_Go, d, a, b, c, w1[3], MD4C01, MD4S11);
353 MD4_STEP (MD4_Go, c, d, a, b, w2[3], MD4C01, MD4S12);
354 MD4_STEP (MD4_Go, b, c, d, a, w3[3], MD4C01, MD4S13);
356 MD4_STEP (MD4_H , a, b, c, d, w0[0], MD4C02, MD4S20);
357 MD4_STEP (MD4_H , d, a, b, c, w2[0], MD4C02, MD4S21);
358 MD4_STEP (MD4_H , c, d, a, b, w1[0], MD4C02, MD4S22);
359 MD4_STEP (MD4_H , b, c, d, a, w3[0], MD4C02, MD4S23);
360 MD4_STEP (MD4_H , a, b, c, d, w0[2], MD4C02, MD4S20);
361 MD4_STEP (MD4_H , d, a, b, c, w2[2], MD4C02, MD4S21);
362 MD4_STEP (MD4_H , c, d, a, b, w1[2], MD4C02, MD4S22);
363 MD4_STEP (MD4_H , b, c, d, a, w3[2], MD4C02, MD4S23);
364 MD4_STEP (MD4_H , a, b, c, d, w0[1], MD4C02, MD4S20);
365 MD4_STEP (MD4_H , d, a, b, c, w2[1], MD4C02, MD4S21);
366 MD4_STEP (MD4_H , c, d, a, b, w1[1], MD4C02, MD4S22);
367 MD4_STEP (MD4_H , b, c, d, a, w3[1], MD4C02, MD4S23);
368 MD4_STEP (MD4_H , a, b, c, d, w0[3], MD4C02, MD4S20);
370 if (MATCHES_NONE_VS (a, search[0])) continue;
372 MD4_STEP (MD4_H , d, a, b, c, w2[3], MD4C02, MD4S21);
373 MD4_STEP (MD4_H , c, d, a, b, w1[3], MD4C02, MD4S22);
374 MD4_STEP (MD4_H , b, c, d, a, w3[3], MD4C02, MD4S23);
376 COMPARE_M_SIMD (a, d, c, b);
380 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
384 __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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)