2 * Authors.....: Jens Steube <jens.steube@gmail.com>
3 * magnum <john.magnum@hushmail.com>
12 #include "inc_vendor.cl"
13 #include "inc_hash_constants.h"
14 #include "inc_hash_functions.cl"
15 #include "inc_types.cl"
16 #include "inc_common.cl"
19 #include "inc_simd.cl"
22 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i)])
24 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1])
26 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3])
28 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7])
30 #define uint_to_hex_lower8(i) (u32x) (l_bin2asc[(i).s0], l_bin2asc[(i).s1], l_bin2asc[(i).s2], l_bin2asc[(i).s3], l_bin2asc[(i).s4], l_bin2asc[(i).s5], l_bin2asc[(i).s6], l_bin2asc[(i).s7], l_bin2asc[(i).s8], l_bin2asc[(i).s9], l_bin2asc[(i).sa], l_bin2asc[(i).sb], l_bin2asc[(i).sc], l_bin2asc[(i).sd], l_bin2asc[(i).se], l_bin2asc[(i).sf])
33 __kernel void m11100_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)
39 const u32 gid = get_global_id (0);
40 const u32 lid = get_local_id (0);
41 const u32 lsz = get_local_size (0);
47 __local u32 l_bin2asc[256];
49 for (u32 i = lid; i < 256; i += lsz)
51 const u32 i0 = (i >> 0) & 15;
52 const u32 i1 = (i >> 4) & 15;
54 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
55 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
58 barrier (CLK_LOCAL_MEM_FENCE);
60 if (gid >= gid_max) return;
69 pw_buf0[0] = pws[gid].i[ 0];
70 pw_buf0[1] = pws[gid].i[ 1];
71 pw_buf0[2] = pws[gid].i[ 2];
72 pw_buf0[3] = pws[gid].i[ 3];
73 pw_buf1[0] = pws[gid].i[ 4];
74 pw_buf1[1] = pws[gid].i[ 5];
75 pw_buf1[2] = pws[gid].i[ 6];
76 pw_buf1[3] = pws[gid].i[ 7];
78 const u32 pw_len = pws[gid].pw_len;
86 challenge = salt_bufs[salt_pos].salt_buf[0];
95 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
96 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
97 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
98 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
99 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
100 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
101 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
102 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
104 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
110 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
117 const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
128 s0[0] = salt_buf0[0];
129 s0[1] = salt_buf0[1];
130 s0[2] = salt_buf0[2];
131 s0[3] = salt_buf0[3];
132 s1[0] = salt_buf1[0];
133 s1[1] = salt_buf1[1];
134 s1[2] = salt_buf1[2];
135 s1[3] = salt_buf1[3];
145 switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len);
147 const u32x pw_salt_len = out_len + salt_len;
163 w3[2] = pw_salt_len * 8;
175 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
176 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
177 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
178 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
179 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
180 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
181 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
182 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
183 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
184 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
185 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
186 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
187 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
188 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
189 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
190 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
192 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
193 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
194 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
195 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
196 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
197 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
198 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
199 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
200 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
201 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
202 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
203 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
204 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
205 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
206 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
207 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
209 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
210 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
211 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
212 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
213 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
214 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
215 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
216 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
217 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
218 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
219 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
220 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
221 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
222 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
223 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
224 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
226 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
227 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
228 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
229 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
230 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
231 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
232 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
233 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
234 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
235 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
236 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
237 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
238 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
239 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
240 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
241 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
248 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
249 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
250 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
251 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
252 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
253 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
254 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
255 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
256 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
257 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
258 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
259 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
260 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
261 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
262 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
263 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
265 // add the 4 byte challenge here
273 w3[2] = (32 + 4) * 8;
277 * md5 ($hash.$challenge)
285 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
286 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
287 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
288 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
289 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
290 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
291 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
292 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
293 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
294 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
295 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
296 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
297 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
298 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
299 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
300 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
302 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
303 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
304 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
305 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
306 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
307 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
308 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
309 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
310 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
311 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
312 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
313 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
314 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
315 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
316 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
317 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
319 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
320 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
321 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
322 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
323 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
324 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
325 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
326 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
327 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
328 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
329 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
330 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
331 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
332 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
333 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
334 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
336 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
337 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
338 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
339 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
340 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
341 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
342 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
343 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
344 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
345 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
346 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
347 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
348 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
349 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
350 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
351 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
353 COMPARE_M_SIMD (a, d, c, b);
357 __kernel void m11100_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)
361 __kernel void m11100_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)
365 __kernel void m11100_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)
371 const u32 gid = get_global_id (0);
372 const u32 lid = get_local_id (0);
373 const u32 lsz = get_local_size (0);
379 __local u32 l_bin2asc[256];
381 for (u32 i = lid; i < 256; i += lsz)
383 const u32 i0 = (i >> 0) & 15;
384 const u32 i1 = (i >> 4) & 15;
386 l_bin2asc[i] = ((i0 < 10) ? '0' + i0 : 'a' - 10 + i0) << 8
387 | ((i1 < 10) ? '0' + i1 : 'a' - 10 + i1) << 0;
390 barrier (CLK_LOCAL_MEM_FENCE);
392 if (gid >= gid_max) return;
401 pw_buf0[0] = pws[gid].i[ 0];
402 pw_buf0[1] = pws[gid].i[ 1];
403 pw_buf0[2] = pws[gid].i[ 2];
404 pw_buf0[3] = pws[gid].i[ 3];
405 pw_buf1[0] = pws[gid].i[ 4];
406 pw_buf1[1] = pws[gid].i[ 5];
407 pw_buf1[2] = pws[gid].i[ 6];
408 pw_buf1[3] = pws[gid].i[ 7];
410 const u32 pw_len = pws[gid].pw_len;
418 challenge = salt_bufs[salt_pos].salt_buf[0];
427 salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 1]; // not a bug, see challenge
428 salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 2];
429 salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 3];
430 salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 4];
431 salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 5];
432 salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 6];
433 salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 7];
434 salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 8];
436 const u32 salt_len = salt_bufs[salt_pos].salt_len - 4;
442 const u32 search[4] =
444 digests_buf[digests_offset].digest_buf[DGST_R0],
445 digests_buf[digests_offset].digest_buf[DGST_R1],
446 digests_buf[digests_offset].digest_buf[DGST_R2],
447 digests_buf[digests_offset].digest_buf[DGST_R3]
454 for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
461 const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
472 s0[0] = salt_buf0[0];
473 s0[1] = salt_buf0[1];
474 s0[2] = salt_buf0[2];
475 s0[3] = salt_buf0[3];
476 s1[0] = salt_buf1[0];
477 s1[1] = salt_buf1[1];
478 s1[2] = salt_buf1[2];
479 s1[3] = salt_buf1[3];
489 switch_buffer_by_offset_le_VV (s0, s1, s2, s3, out_len);
491 const u32x pw_salt_len = out_len + salt_len;
507 w3[2] = pw_salt_len * 8;
519 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
520 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
521 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
522 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
523 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
524 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
525 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
526 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
527 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
528 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
529 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
530 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
531 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
532 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
533 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
534 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
536 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
537 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
538 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
539 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
540 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
541 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
542 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
543 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
544 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
545 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
546 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
547 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
548 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
549 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
550 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
551 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
553 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
554 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
555 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
556 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
557 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
558 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
559 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
560 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
561 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
562 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
563 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
564 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
565 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
566 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
567 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
568 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
570 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
571 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
572 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
573 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
574 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
575 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
576 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
577 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
578 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
579 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
580 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
581 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
582 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
583 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
584 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
585 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
592 w0[0] = uint_to_hex_lower8 ((a >> 0) & 255) << 0
593 | uint_to_hex_lower8 ((a >> 8) & 255) << 16;
594 w0[1] = uint_to_hex_lower8 ((a >> 16) & 255) << 0
595 | uint_to_hex_lower8 ((a >> 24) & 255) << 16;
596 w0[2] = uint_to_hex_lower8 ((b >> 0) & 255) << 0
597 | uint_to_hex_lower8 ((b >> 8) & 255) << 16;
598 w0[3] = uint_to_hex_lower8 ((b >> 16) & 255) << 0
599 | uint_to_hex_lower8 ((b >> 24) & 255) << 16;
600 w1[0] = uint_to_hex_lower8 ((c >> 0) & 255) << 0
601 | uint_to_hex_lower8 ((c >> 8) & 255) << 16;
602 w1[1] = uint_to_hex_lower8 ((c >> 16) & 255) << 0
603 | uint_to_hex_lower8 ((c >> 24) & 255) << 16;
604 w1[2] = uint_to_hex_lower8 ((d >> 0) & 255) << 0
605 | uint_to_hex_lower8 ((d >> 8) & 255) << 16;
606 w1[3] = uint_to_hex_lower8 ((d >> 16) & 255) << 0
607 | uint_to_hex_lower8 ((d >> 24) & 255) << 16;
609 // add the 4 byte challenge here
617 w3[2] = (32 + 4) * 8;
621 * md5 ($hash.$challenge)
629 MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
630 MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
631 MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
632 MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
633 MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
634 MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
635 MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
636 MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
637 MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
638 MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
639 MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
640 MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
641 MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
642 MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
643 MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
644 MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
646 MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
647 MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
648 MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
649 MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
650 MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
651 MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
652 MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
653 MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
654 MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
655 MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
656 MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
657 MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
658 MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
659 MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
660 MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
661 MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
663 MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
664 MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
665 MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
666 MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
667 MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
668 MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
669 MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
670 MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
671 MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
672 MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
673 MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
674 MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
675 MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
676 MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
677 MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
678 MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
680 MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
681 MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
682 MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
683 MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
684 MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
685 MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
686 MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
687 MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
688 MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
689 MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
690 MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
691 MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
692 MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
694 if (MATCHES_NONE_VS (a, search[0])) continue;
696 MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
697 MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
698 MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
700 COMPARE_S_SIMD (a, d, c, b);
704 __kernel void m11100_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)
708 __kernel void m11100_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)