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 #define uint_to_hex_lower8(i) l_bin2asc[(i)]
25 __kernel void m03710_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)
31 const u32 gid = get_global_id (0);
32 const u32 lid = get_local_id (0);
33 const u32 lsz = get_local_size (0);
39 __local u32 l_bin2asc[256];
41 for (u32 i = lid; i < 256; i += lsz)
43 const u32 i0 = (i >> 0) & 15;
44 const u32 i1 = (i >> 4) & 15;
46 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
47 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
50 barrier (CLK_LOCAL_MEM_FENCE);
52 if (gid >= gid_max) return;
61 pws0[0] = pws[gid].i[0];
62 pws0[1] = pws[gid].i[1];
63 pws0[2] = pws[gid].i[2];
64 pws0[3] = pws[gid].i[3];
65 pws1[0] = pws[gid].i[4];
66 pws1[1] = pws[gid].i[5];
67 pws1[2] = pws[gid].i[6];
68 pws1[3] = pws[gid].i[7];
70 const u32 pw_l_len = pws[gid].pw_len;
78 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
79 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
80 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
81 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
85 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
86 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
87 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
88 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
104 const u32 salt_len = salt_bufs[salt_pos].salt_len;
106 const u32 pw_salt_len = 32 + salt_len;
112 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
114 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
116 const u32x pw_len = pw_l_len + pw_r_len;
118 u32x wordr0[4] = { 0 };
119 u32x wordr1[4] = { 0 };
120 u32x wordr2[4] = { 0 };
121 u32x wordr3[4] = { 0 };
123 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
124 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
125 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
126 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
127 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
128 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
129 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
130 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
132 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
134 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
139 w0[0] = wordl0[0] | wordr0[0];
140 w0[1] = wordl0[1] | wordr0[1];
141 w0[2] = wordl0[2] | wordr0[2];
142 w0[3] = wordl0[3] | wordr0[3];
146 w1[0] = wordl1[0] | wordr1[0];
147 w1[1] = wordl1[1] | wordr1[1];
148 w1[2] = wordl1[2] | wordr1[2];
149 w1[3] = wordl1[3] | wordr1[3];
153 w2[0] = wordl2[0] | wordr2[0];
154 w2[1] = wordl2[1] | wordr2[1];
155 w2[2] = wordl2[2] | wordr2[2];
156 w2[3] = wordl2[3] | wordr2[3];
160 w3[0] = wordl3[0] | wordr3[0];
161 w3[1] = wordl3[1] | wordr3[1];
170 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
171 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
172 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
173 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
174 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
175 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
176 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
177 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
178 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
179 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
180 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
181 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
182 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
183 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
184 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
185 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
187 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
188 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
189 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
190 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
191 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
192 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
193 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
194 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
195 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
196 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
197 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
198 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
199 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
200 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
201 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
202 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
204 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
205 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
206 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
207 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
208 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
209 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
210 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
211 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
212 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
213 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
214 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
215 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
216 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
217 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
218 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
219 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
221 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
222 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
223 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
224 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
225 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
226 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
227 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
228 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
229 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
230 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
231 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
232 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
233 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
234 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
235 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
236 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
248 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
249 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
250 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
251 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
252 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
253 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
254 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
255 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
256 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
257 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
258 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
259 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
260 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
261 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
262 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
263 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
265 w2_t[0] = 0x00000080;
279 switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, salt_len);
281 w3_t[2] = pw_salt_len * 8;
283 w0_t[0] |= salt_buf0[0];
284 w0_t[1] |= salt_buf0[1];
285 w0_t[2] |= salt_buf0[2];
286 w0_t[3] |= salt_buf0[3];
287 w1_t[0] |= salt_buf1[0];
288 w1_t[1] |= salt_buf1[1];
289 w1_t[2] |= salt_buf1[2];
290 w1_t[3] |= salt_buf1[3];
291 w2_t[0] |= salt_buf2[0];
292 w2_t[1] |= salt_buf2[1];
293 w2_t[2] |= salt_buf2[2];
294 w2_t[3] |= salt_buf2[3];
295 w3_t[0] |= salt_buf3[0];
296 w3_t[1] |= salt_buf3[1];
297 w3_t[2] |= salt_buf3[2];
298 w3_t[3] |= salt_buf3[3];
309 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
310 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
311 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
312 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
313 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
314 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
315 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
316 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
317 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
318 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
319 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
320 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
321 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
322 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
323 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
324 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
326 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
327 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
328 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
329 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
330 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
331 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
332 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
333 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
334 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
335 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
336 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
337 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
338 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
339 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
340 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
341 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
343 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
344 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
345 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
346 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
347 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
348 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
349 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
350 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
351 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
352 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
353 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
354 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
355 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
356 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
357 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
358 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
360 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
361 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
362 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
363 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
364 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
365 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
366 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
367 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
368 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
369 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
370 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
371 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
372 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
373 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
374 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
375 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
376 COMPARE_M_SIMD (a, d, c, b);
380 __kernel void m03710_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)
384 __kernel void m03710_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)
388 __kernel void m03710_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)
394 const u32 gid = get_global_id (0);
395 const u32 lid = get_local_id (0);
396 const u32 lsz = get_local_size (0);
402 __local u32 l_bin2asc[256];
404 for (u32 i = lid; i < 256; i += lsz)
406 const u32 i0 = (i >> 0) & 15;
407 const u32 i1 = (i >> 4) & 15;
409 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
410 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
413 barrier (CLK_LOCAL_MEM_FENCE);
415 if (gid >= gid_max) return;
424 pws0[0] = pws[gid].i[0];
425 pws0[1] = pws[gid].i[1];
426 pws0[2] = pws[gid].i[2];
427 pws0[3] = pws[gid].i[3];
428 pws1[0] = pws[gid].i[4];
429 pws1[1] = pws[gid].i[5];
430 pws1[2] = pws[gid].i[6];
431 pws1[3] = pws[gid].i[7];
433 const u32 pw_l_len = pws[gid].pw_len;
441 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
442 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
443 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
444 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
448 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
449 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
450 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
451 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
467 const u32 salt_len = salt_bufs[salt_pos].salt_len;
469 const u32 pw_salt_len = 32 + salt_len;
475 const u32 search[4] =
477 digests_buf[digests_offset].digest_buf[DGST_R0],
478 digests_buf[digests_offset].digest_buf[DGST_R1],
479 digests_buf[digests_offset].digest_buf[DGST_R2],
480 digests_buf[digests_offset].digest_buf[DGST_R3]
487 for (u32 il_pos = 0; il_pos < combs_cnt; il_pos += VECT_SIZE)
489 const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
491 const u32x pw_len = pw_l_len + pw_r_len;
493 u32x wordr0[4] = { 0 };
494 u32x wordr1[4] = { 0 };
495 u32x wordr2[4] = { 0 };
496 u32x wordr3[4] = { 0 };
498 wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
499 wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
500 wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
501 wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
502 wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
503 wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
504 wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
505 wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
507 if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
509 switch_buffer_by_offset_le (wordr0, wordr1, wordr2, wordr3, pw_l_len);
514 w0[0] = wordl0[0] | wordr0[0];
515 w0[1] = wordl0[1] | wordr0[1];
516 w0[2] = wordl0[2] | wordr0[2];
517 w0[3] = wordl0[3] | wordr0[3];
521 w1[0] = wordl1[0] | wordr1[0];
522 w1[1] = wordl1[1] | wordr1[1];
523 w1[2] = wordl1[2] | wordr1[2];
524 w1[3] = wordl1[3] | wordr1[3];
528 w2[0] = wordl2[0] | wordr2[0];
529 w2[1] = wordl2[1] | wordr2[1];
530 w2[2] = wordl2[2] | wordr2[2];
531 w2[3] = wordl2[3] | wordr2[3];
535 w3[0] = wordl3[0] | wordr3[0];
536 w3[1] = wordl3[1] | wordr3[1];
545 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
546 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
547 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
548 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
549 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
550 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
551 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
552 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
553 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
554 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
555 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
556 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
557 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
558 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
559 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
560 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
562 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
563 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
564 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
565 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
566 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
567 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
568 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
569 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
570 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
571 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
572 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
573 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
574 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
575 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
576 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
577 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
579 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
580 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
581 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
582 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
583 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
584 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
585 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
586 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
587 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
588 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
589 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
590 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
591 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
592 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
593 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
594 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
596 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
597 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
598 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
599 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
600 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
601 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
602 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
603 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
604 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
605 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
606 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
607 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
608 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
609 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
610 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
611 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
623 w0_t[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
624 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
625 w0_t[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
626 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
627 w0_t[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
628 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
629 w0_t[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
630 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
631 w1_t[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
632 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
633 w1_t[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
634 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
635 w1_t[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
636 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
637 w1_t[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
638 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
640 w2_t[0] = 0x00000080;
654 switch_buffer_by_offset_le (w0_t, w1_t, w2_t, w3_t, salt_len);
656 w3_t[2] = pw_salt_len * 8;
658 w0_t[0] |= salt_buf0[0];
659 w0_t[1] |= salt_buf0[1];
660 w0_t[2] |= salt_buf0[2];
661 w0_t[3] |= salt_buf0[3];
662 w1_t[0] |= salt_buf1[0];
663 w1_t[1] |= salt_buf1[1];
664 w1_t[2] |= salt_buf1[2];
665 w1_t[3] |= salt_buf1[3];
666 w2_t[0] |= salt_buf2[0];
667 w2_t[1] |= salt_buf2[1];
668 w2_t[2] |= salt_buf2[2];
669 w2_t[3] |= salt_buf2[3];
670 w3_t[0] |= salt_buf3[0];
671 w3_t[1] |= salt_buf3[1];
672 w3_t[2] |= salt_buf3[2];
673 w3_t[3] |= salt_buf3[3];
684 MD5_STEP (MD5_Fo, a, b, c, d, w0_t[0], MD5C00, MD5S00);
685 MD5_STEP (MD5_Fo, d, a, b, c, w0_t[1], MD5C01, MD5S01);
686 MD5_STEP (MD5_Fo, c, d, a, b, w0_t[2], MD5C02, MD5S02);
687 MD5_STEP (MD5_Fo, b, c, d, a, w0_t[3], MD5C03, MD5S03);
688 MD5_STEP (MD5_Fo, a, b, c, d, w1_t[0], MD5C04, MD5S00);
689 MD5_STEP (MD5_Fo, d, a, b, c, w1_t[1], MD5C05, MD5S01);
690 MD5_STEP (MD5_Fo, c, d, a, b, w1_t[2], MD5C06, MD5S02);
691 MD5_STEP (MD5_Fo, b, c, d, a, w1_t[3], MD5C07, MD5S03);
692 MD5_STEP (MD5_Fo, a, b, c, d, w2_t[0], MD5C08, MD5S00);
693 MD5_STEP (MD5_Fo, d, a, b, c, w2_t[1], MD5C09, MD5S01);
694 MD5_STEP (MD5_Fo, c, d, a, b, w2_t[2], MD5C0a, MD5S02);
695 MD5_STEP (MD5_Fo, b, c, d, a, w2_t[3], MD5C0b, MD5S03);
696 MD5_STEP (MD5_Fo, a, b, c, d, w3_t[0], MD5C0c, MD5S00);
697 MD5_STEP (MD5_Fo, d, a, b, c, w3_t[1], MD5C0d, MD5S01);
698 MD5_STEP (MD5_Fo, c, d, a, b, w3_t[2], MD5C0e, MD5S02);
699 MD5_STEP (MD5_Fo, b, c, d, a, w3_t[3], MD5C0f, MD5S03);
701 MD5_STEP (MD5_Go, a, b, c, d, w0_t[1], MD5C10, MD5S10);
702 MD5_STEP (MD5_Go, d, a, b, c, w1_t[2], MD5C11, MD5S11);
703 MD5_STEP (MD5_Go, c, d, a, b, w2_t[3], MD5C12, MD5S12);
704 MD5_STEP (MD5_Go, b, c, d, a, w0_t[0], MD5C13, MD5S13);
705 MD5_STEP (MD5_Go, a, b, c, d, w1_t[1], MD5C14, MD5S10);
706 MD5_STEP (MD5_Go, d, a, b, c, w2_t[2], MD5C15, MD5S11);
707 MD5_STEP (MD5_Go, c, d, a, b, w3_t[3], MD5C16, MD5S12);
708 MD5_STEP (MD5_Go, b, c, d, a, w1_t[0], MD5C17, MD5S13);
709 MD5_STEP (MD5_Go, a, b, c, d, w2_t[1], MD5C18, MD5S10);
710 MD5_STEP (MD5_Go, d, a, b, c, w3_t[2], MD5C19, MD5S11);
711 MD5_STEP (MD5_Go, c, d, a, b, w0_t[3], MD5C1a, MD5S12);
712 MD5_STEP (MD5_Go, b, c, d, a, w2_t[0], MD5C1b, MD5S13);
713 MD5_STEP (MD5_Go, a, b, c, d, w3_t[1], MD5C1c, MD5S10);
714 MD5_STEP (MD5_Go, d, a, b, c, w0_t[2], MD5C1d, MD5S11);
715 MD5_STEP (MD5_Go, c, d, a, b, w1_t[3], MD5C1e, MD5S12);
716 MD5_STEP (MD5_Go, b, c, d, a, w3_t[0], MD5C1f, MD5S13);
718 MD5_STEP (MD5_H , a, b, c, d, w1_t[1], MD5C20, MD5S20);
719 MD5_STEP (MD5_H , d, a, b, c, w2_t[0], MD5C21, MD5S21);
720 MD5_STEP (MD5_H , c, d, a, b, w2_t[3], MD5C22, MD5S22);
721 MD5_STEP (MD5_H , b, c, d, a, w3_t[2], MD5C23, MD5S23);
722 MD5_STEP (MD5_H , a, b, c, d, w0_t[1], MD5C24, MD5S20);
723 MD5_STEP (MD5_H , d, a, b, c, w1_t[0], MD5C25, MD5S21);
724 MD5_STEP (MD5_H , c, d, a, b, w1_t[3], MD5C26, MD5S22);
725 MD5_STEP (MD5_H , b, c, d, a, w2_t[2], MD5C27, MD5S23);
726 MD5_STEP (MD5_H , a, b, c, d, w3_t[1], MD5C28, MD5S20);
727 MD5_STEP (MD5_H , d, a, b, c, w0_t[0], MD5C29, MD5S21);
728 MD5_STEP (MD5_H , c, d, a, b, w0_t[3], MD5C2a, MD5S22);
729 MD5_STEP (MD5_H , b, c, d, a, w1_t[2], MD5C2b, MD5S23);
730 MD5_STEP (MD5_H , a, b, c, d, w2_t[1], MD5C2c, MD5S20);
731 MD5_STEP (MD5_H , d, a, b, c, w3_t[0], MD5C2d, MD5S21);
732 MD5_STEP (MD5_H , c, d, a, b, w3_t[3], MD5C2e, MD5S22);
733 MD5_STEP (MD5_H , b, c, d, a, w0_t[2], MD5C2f, MD5S23);
735 MD5_STEP (MD5_I , a, b, c, d, w0_t[0], MD5C30, MD5S30);
736 MD5_STEP (MD5_I , d, a, b, c, w1_t[3], MD5C31, MD5S31);
737 MD5_STEP (MD5_I , c, d, a, b, w3_t[2], MD5C32, MD5S32);
738 MD5_STEP (MD5_I , b, c, d, a, w1_t[1], MD5C33, MD5S33);
739 MD5_STEP (MD5_I , a, b, c, d, w3_t[0], MD5C34, MD5S30);
740 MD5_STEP (MD5_I , d, a, b, c, w0_t[3], MD5C35, MD5S31);
741 MD5_STEP (MD5_I , c, d, a, b, w2_t[2], MD5C36, MD5S32);
742 MD5_STEP (MD5_I , b, c, d, a, w0_t[1], MD5C37, MD5S33);
743 MD5_STEP (MD5_I , a, b, c, d, w2_t[0], MD5C38, MD5S30);
744 MD5_STEP (MD5_I , d, a, b, c, w3_t[3], MD5C39, MD5S31);
745 MD5_STEP (MD5_I , c, d, a, b, w1_t[2], MD5C3a, MD5S32);
746 MD5_STEP (MD5_I , b, c, d, a, w3_t[1], MD5C3b, MD5S33);
747 MD5_STEP (MD5_I , a, b, c, d, w1_t[0], MD5C3c, MD5S30);
748 MD5_STEP (MD5_I , d, a, b, c, w2_t[3], MD5C3d, MD5S31);
749 MD5_STEP (MD5_I , c, d, a, b, w0_t[2], MD5C3e, MD5S32);
750 MD5_STEP (MD5_I , b, c, d, a, w2_t[1], MD5C3f, MD5S33);
751 COMPARE_S_SIMD (a, d, c, b);
755 __kernel void m03710_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)
759 __kernel void m03710_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)