Initial commit
[hashcat.git] / amd / m00050_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #ifdef  VLIW1
12 #define VECT_SIZE1
13 #endif
14
15 #ifdef  VLIW4
16 #define VECT_SIZE4
17 #endif
18
19 #ifdef  VLIW5
20 #define VECT_SIZE4
21 #endif
22
23 #define DGST_R0 0
24 #define DGST_R1 3
25 #define DGST_R2 2
26 #define DGST_R3 1
27
28 #include "include/kernel_functions.c"
29 #include "types_amd.c"
30 #include "common_amd.c"
31
32 #ifdef  VECT_SIZE1
33 #define VECT_COMPARE_S "check_single_vect1_comp4.c"
34 #define VECT_COMPARE_M "check_multi_vect1_comp4.c"
35 #endif
36
37 #ifdef  VECT_SIZE4
38 #define VECT_COMPARE_S "check_single_vect4_comp4.c"
39 #define VECT_COMPARE_M "check_multi_vect4_comp4.c"
40 #endif
41
42 static void md5_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[4])
43 {
44   u32x a = digest[0];
45   u32x b = digest[1];
46   u32x c = digest[2];
47   u32x d = digest[3];
48
49   u32x w0_t = w0[0];
50   u32x w1_t = w0[1];
51   u32x w2_t = w0[2];
52   u32x w3_t = w0[3];
53   u32x w4_t = w1[0];
54   u32x w5_t = w1[1];
55   u32x w6_t = w1[2];
56   u32x w7_t = w1[3];
57   u32x w8_t = w2[0];
58   u32x w9_t = w2[1];
59   u32x wa_t = w2[2];
60   u32x wb_t = w2[3];
61   u32x wc_t = w3[0];
62   u32x wd_t = w3[1];
63   u32x we_t = w3[2];
64   u32x wf_t = w3[3];
65
66   u32x tmp2;
67
68   MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
69   MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
70   MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
71   MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
72   MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
73   MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
74   MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
75   MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
76   MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
77   MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
78   MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
79   MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
80   MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
81   MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
82   MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
83   MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
84
85   MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
86   MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
87   MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
88   MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
89   MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
90   MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
91   MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
92   MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
93   MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
94   MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
95   MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
96   MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
97   MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
98   MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
99   MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
100   MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
101
102   MD5_STEP (MD5_H1, a, b, c, d, w5_t, MD5C20, MD5S20);
103   MD5_STEP (MD5_H2, d, a, b, c, w8_t, MD5C21, MD5S21);
104   MD5_STEP (MD5_H1, c, d, a, b, wb_t, MD5C22, MD5S22);
105   MD5_STEP (MD5_H2, b, c, d, a, we_t, MD5C23, MD5S23);
106   MD5_STEP (MD5_H1, a, b, c, d, w1_t, MD5C24, MD5S20);
107   MD5_STEP (MD5_H2, d, a, b, c, w4_t, MD5C25, MD5S21);
108   MD5_STEP (MD5_H1, c, d, a, b, w7_t, MD5C26, MD5S22);
109   MD5_STEP (MD5_H2, b, c, d, a, wa_t, MD5C27, MD5S23);
110   MD5_STEP (MD5_H1, a, b, c, d, wd_t, MD5C28, MD5S20);
111   MD5_STEP (MD5_H2, d, a, b, c, w0_t, MD5C29, MD5S21);
112   MD5_STEP (MD5_H1, c, d, a, b, w3_t, MD5C2a, MD5S22);
113   MD5_STEP (MD5_H2, b, c, d, a, w6_t, MD5C2b, MD5S23);
114   MD5_STEP (MD5_H1, a, b, c, d, w9_t, MD5C2c, MD5S20);
115   MD5_STEP (MD5_H2, d, a, b, c, wc_t, MD5C2d, MD5S21);
116   MD5_STEP (MD5_H1, c, d, a, b, wf_t, MD5C2e, MD5S22);
117   MD5_STEP (MD5_H2, b, c, d, a, w2_t, MD5C2f, MD5S23);
118
119   MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
120   MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
121   MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
122   MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
123   MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
124   MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
125   MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
126   MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
127   MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
128   MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
129   MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
130   MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
131   MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
132   MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
133   MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
134   MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
135
136   digest[0] += a;
137   digest[1] += b;
138   digest[2] += c;
139   digest[3] += d;
140 }
141
142 static void hmac_md5_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[4], u32x opad[4])
143 {
144   w0[0] = w0[0] ^ 0x36363636;
145   w0[1] = w0[1] ^ 0x36363636;
146   w0[2] = w0[2] ^ 0x36363636;
147   w0[3] = w0[3] ^ 0x36363636;
148   w1[0] = w1[0] ^ 0x36363636;
149   w1[1] = w1[1] ^ 0x36363636;
150   w1[2] = w1[2] ^ 0x36363636;
151   w1[3] = w1[3] ^ 0x36363636;
152   w2[0] = w2[0] ^ 0x36363636;
153   w2[1] = w2[1] ^ 0x36363636;
154   w2[2] = w2[2] ^ 0x36363636;
155   w2[3] = w2[3] ^ 0x36363636;
156   w3[0] = w3[0] ^ 0x36363636;
157   w3[1] = w3[1] ^ 0x36363636;
158   w3[2] = w3[2] ^ 0x36363636;
159   w3[3] = w3[3] ^ 0x36363636;
160
161   ipad[0] = MD5M_A;
162   ipad[1] = MD5M_B;
163   ipad[2] = MD5M_C;
164   ipad[3] = MD5M_D;
165
166   md5_transform (w0, w1, w2, w3, ipad);
167
168   w0[0] = w0[0] ^ 0x6a6a6a6a;
169   w0[1] = w0[1] ^ 0x6a6a6a6a;
170   w0[2] = w0[2] ^ 0x6a6a6a6a;
171   w0[3] = w0[3] ^ 0x6a6a6a6a;
172   w1[0] = w1[0] ^ 0x6a6a6a6a;
173   w1[1] = w1[1] ^ 0x6a6a6a6a;
174   w1[2] = w1[2] ^ 0x6a6a6a6a;
175   w1[3] = w1[3] ^ 0x6a6a6a6a;
176   w2[0] = w2[0] ^ 0x6a6a6a6a;
177   w2[1] = w2[1] ^ 0x6a6a6a6a;
178   w2[2] = w2[2] ^ 0x6a6a6a6a;
179   w2[3] = w2[3] ^ 0x6a6a6a6a;
180   w3[0] = w3[0] ^ 0x6a6a6a6a;
181   w3[1] = w3[1] ^ 0x6a6a6a6a;
182   w3[2] = w3[2] ^ 0x6a6a6a6a;
183   w3[3] = w3[3] ^ 0x6a6a6a6a;
184
185   opad[0] = MD5M_A;
186   opad[1] = MD5M_B;
187   opad[2] = MD5M_C;
188   opad[3] = MD5M_D;
189
190   md5_transform (w0, w1, w2, w3, opad);
191 }
192
193 static void hmac_md5_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[4], u32x opad[4], u32x digest[4])
194 {
195   digest[0] = ipad[0];
196   digest[1] = ipad[1];
197   digest[2] = ipad[2];
198   digest[3] = ipad[3];
199
200   md5_transform (w0, w1, w2, w3, digest);
201
202   w0[0] = digest[0];
203   w0[1] = digest[1];
204   w0[2] = digest[2];
205   w0[3] = digest[3];
206   w1[0] = 0x80;
207   w1[1] = 0;
208   w1[2] = 0;
209   w1[3] = 0;
210   w2[0] = 0;
211   w2[1] = 0;
212   w2[2] = 0;
213   w2[3] = 0;
214   w3[0] = 0;
215   w3[1] = 0;
216   w3[2] = (64 + 16) * 8;
217   w3[3] = 0;
218
219   digest[0] = opad[0];
220   digest[1] = opad[1];
221   digest[2] = opad[2];
222   digest[3] = opad[3];
223
224   md5_transform (w0, w1, w2, w3, digest);
225 }
226
227 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00050_m04 (__global pw_t *pws, __global gpu_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)
228 {
229   /**
230    * modifier
231    */
232
233   const u32 lid = get_local_id (0);
234
235   /**
236    * base
237    */
238
239   const u32 gid = get_global_id (0);
240
241   if (gid >= gid_max) return;
242
243   u32x wordl0[4];
244
245   wordl0[0] = pws[gid].i[ 0];
246   wordl0[1] = pws[gid].i[ 1];
247   wordl0[2] = pws[gid].i[ 2];
248   wordl0[3] = pws[gid].i[ 3];
249
250   u32x wordl1[4];
251
252   wordl1[0] = pws[gid].i[ 4];
253   wordl1[1] = pws[gid].i[ 5];
254   wordl1[2] = pws[gid].i[ 6];
255   wordl1[3] = pws[gid].i[ 7];
256
257   u32x wordl2[4];
258
259   wordl2[0] = 0;
260   wordl2[1] = 0;
261   wordl2[2] = 0;
262   wordl2[3] = 0;
263
264   u32x wordl3[4];
265
266   wordl3[0] = 0;
267   wordl3[1] = 0;
268   wordl3[2] = 0;
269   wordl3[3] = 0;
270
271   const u32 pw_l_len = pws[gid].pw_len;
272
273   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
274   {
275     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
276   }
277
278   /**
279    * salt
280    */
281
282   u32 salt_buf0[4];
283
284   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
285   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
286   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
287   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
288
289   u32 salt_buf1[4];
290
291   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
292   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
293   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
294   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
295
296   u32 salt_buf2[4];
297
298   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
299   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
300   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
301   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
302
303   u32 salt_buf3[4];
304
305   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
306   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
307   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
308   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
309
310   const u32 salt_len = salt_bufs[salt_pos].salt_len;
311
312   /**
313    * loop
314    */
315
316   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
317   {
318     const u32 pw_r_len = combs_buf[il_pos].pw_len;
319
320     const u32 pw_len = pw_l_len + pw_r_len;
321
322     u32 wordr0[4];
323
324     wordr0[0] = combs_buf[il_pos].i[0];
325     wordr0[1] = combs_buf[il_pos].i[1];
326     wordr0[2] = combs_buf[il_pos].i[2];
327     wordr0[3] = combs_buf[il_pos].i[3];
328
329     u32 wordr1[4];
330
331     wordr1[0] = combs_buf[il_pos].i[4];
332     wordr1[1] = combs_buf[il_pos].i[5];
333     wordr1[2] = combs_buf[il_pos].i[6];
334     wordr1[3] = combs_buf[il_pos].i[7];
335
336     u32 wordr2[4];
337
338     wordr2[0] = 0;
339     wordr2[1] = 0;
340     wordr2[2] = 0;
341     wordr2[3] = 0;
342
343     u32 wordr3[4];
344
345     wordr3[0] = 0;
346     wordr3[1] = 0;
347     wordr3[2] = 0;
348     wordr3[3] = 0;
349
350     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
351     {
352       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
353     }
354
355     u32x w0[4];
356
357     w0[0] = wordl0[0] | wordr0[0];
358     w0[1] = wordl0[1] | wordr0[1];
359     w0[2] = wordl0[2] | wordr0[2];
360     w0[3] = wordl0[3] | wordr0[3];
361
362     u32x w1[4];
363
364     w1[0] = wordl1[0] | wordr1[0];
365     w1[1] = wordl1[1] | wordr1[1];
366     w1[2] = wordl1[2] | wordr1[2];
367     w1[3] = wordl1[3] | wordr1[3];
368
369     u32x w2[4];
370
371     w2[0] = wordl2[0] | wordr2[0];
372     w2[1] = wordl2[1] | wordr2[1];
373     w2[2] = wordl2[2] | wordr2[2];
374     w2[3] = wordl2[3] | wordr2[3];
375
376     u32x w3[4];
377
378     w3[0] = wordl3[0] | wordr3[0];
379     w3[1] = wordl3[1] | wordr3[1];
380     w3[2] = wordl3[2] | wordr3[2];
381     w3[3] = wordl3[3] | wordr3[3];
382
383     /**
384      * pads
385      */
386
387     u32x w0_t[4];
388
389     w0_t[0] = w0[0];
390     w0_t[1] = w0[1];
391     w0_t[2] = w0[2];
392     w0_t[3] = w0[3];
393
394     u32x w1_t[4];
395
396     w1_t[0] = w1[0];
397     w1_t[1] = w1[1];
398     w1_t[2] = w1[2];
399     w1_t[3] = w1[3];
400
401     u32x w2_t[4];
402
403     w2_t[0] = 0;
404     w2_t[1] = 0;
405     w2_t[2] = 0;
406     w2_t[3] = 0;
407
408     u32x w3_t[4];
409
410     w3_t[0] = 0;
411     w3_t[1] = 0;
412     w3_t[2] = 0;
413     w3_t[3] = 0;
414
415     u32x ipad[4];
416     u32x opad[4];
417
418     hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
419
420     w0_t[0] = salt_buf0[0];
421     w0_t[1] = salt_buf0[1];
422     w0_t[2] = salt_buf0[2];
423     w0_t[3] = salt_buf0[3];
424     w1_t[0] = salt_buf1[0];
425     w1_t[1] = salt_buf1[1];
426     w1_t[2] = salt_buf1[2];
427     w1_t[3] = salt_buf1[3];
428     w2_t[0] = salt_buf2[0];
429     w2_t[1] = salt_buf2[1];
430     w2_t[2] = salt_buf2[2];
431     w2_t[3] = salt_buf2[3];
432     w3_t[0] = salt_buf3[0];
433     w3_t[1] = salt_buf3[1];
434     w3_t[2] = (64 + salt_len) * 8;
435     w3_t[3] = 0;
436
437     u32x digest[4];
438
439     hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
440
441     const u32x r0 = digest[0];
442     const u32x r1 = digest[3];
443     const u32x r2 = digest[2];
444     const u32x r3 = digest[1];
445
446     #include VECT_COMPARE_M
447   }
448 }
449
450 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00050_m08 (__global pw_t *pws, __global gpu_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)
451 {
452 }
453
454 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00050_m16 (__global pw_t *pws, __global gpu_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)
455 {
456 }
457
458 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00050_s04 (__global pw_t *pws, __global gpu_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)
459 {
460   /**
461    * modifier
462    */
463
464   const u32 lid = get_local_id (0);
465
466   /**
467    * base
468    */
469
470   const u32 gid = get_global_id (0);
471
472   if (gid >= gid_max) return;
473
474   u32x wordl0[4];
475
476   wordl0[0] = pws[gid].i[ 0];
477   wordl0[1] = pws[gid].i[ 1];
478   wordl0[2] = pws[gid].i[ 2];
479   wordl0[3] = pws[gid].i[ 3];
480
481   u32x wordl1[4];
482
483   wordl1[0] = pws[gid].i[ 4];
484   wordl1[1] = pws[gid].i[ 5];
485   wordl1[2] = pws[gid].i[ 6];
486   wordl1[3] = pws[gid].i[ 7];
487
488   u32x wordl2[4];
489
490   wordl2[0] = 0;
491   wordl2[1] = 0;
492   wordl2[2] = 0;
493   wordl2[3] = 0;
494
495   u32x wordl3[4];
496
497   wordl3[0] = 0;
498   wordl3[1] = 0;
499   wordl3[2] = 0;
500   wordl3[3] = 0;
501
502   const u32 pw_l_len = pws[gid].pw_len;
503
504   if (combs_mode == COMBINATOR_MODE_BASE_RIGHT)
505   {
506     switch_buffer_by_offset (wordl0, wordl1, wordl2, wordl3, combs_buf[0].pw_len);
507   }
508
509   /**
510    * salt
511    */
512
513   u32 salt_buf0[4];
514
515   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
516   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
517   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
518   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
519
520   u32 salt_buf1[4];
521
522   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
523   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
524   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
525   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
526
527   u32 salt_buf2[4];
528
529   salt_buf2[0] = salt_bufs[salt_pos].salt_buf[ 8];
530   salt_buf2[1] = salt_bufs[salt_pos].salt_buf[ 9];
531   salt_buf2[2] = salt_bufs[salt_pos].salt_buf[10];
532   salt_buf2[3] = salt_bufs[salt_pos].salt_buf[11];
533
534   u32 salt_buf3[4];
535
536   salt_buf3[0] = salt_bufs[salt_pos].salt_buf[12];
537   salt_buf3[1] = salt_bufs[salt_pos].salt_buf[13];
538   salt_buf3[2] = salt_bufs[salt_pos].salt_buf[14];
539   salt_buf3[3] = salt_bufs[salt_pos].salt_buf[15];
540
541   const u32 salt_len = salt_bufs[salt_pos].salt_len;
542
543   /**
544    * digest
545    */
546
547   const u32 search[4] =
548   {
549     digests_buf[digests_offset].digest_buf[DGST_R0],
550     digests_buf[digests_offset].digest_buf[DGST_R1],
551     digests_buf[digests_offset].digest_buf[DGST_R2],
552     digests_buf[digests_offset].digest_buf[DGST_R3]
553   };
554
555   /**
556    * loop
557    */
558
559   for (u32 il_pos = 0; il_pos < combs_cnt; il_pos++)
560   {
561     const u32 pw_r_len = combs_buf[il_pos].pw_len;
562
563     const u32 pw_len = pw_l_len + pw_r_len;
564
565     u32 wordr0[4];
566
567     wordr0[0] = combs_buf[il_pos].i[0];
568     wordr0[1] = combs_buf[il_pos].i[1];
569     wordr0[2] = combs_buf[il_pos].i[2];
570     wordr0[3] = combs_buf[il_pos].i[3];
571
572     u32 wordr1[4];
573
574     wordr1[0] = combs_buf[il_pos].i[4];
575     wordr1[1] = combs_buf[il_pos].i[5];
576     wordr1[2] = combs_buf[il_pos].i[6];
577     wordr1[3] = combs_buf[il_pos].i[7];
578
579     u32 wordr2[4];
580
581     wordr2[0] = 0;
582     wordr2[1] = 0;
583     wordr2[2] = 0;
584     wordr2[3] = 0;
585
586     u32 wordr3[4];
587
588     wordr3[0] = 0;
589     wordr3[1] = 0;
590     wordr3[2] = 0;
591     wordr3[3] = 0;
592
593     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
594     {
595       switch_buffer_by_offset (wordr0, wordr1, wordr2, wordr3, pw_l_len);
596     }
597
598     u32x w0[4];
599
600     w0[0] = wordl0[0] | wordr0[0];
601     w0[1] = wordl0[1] | wordr0[1];
602     w0[2] = wordl0[2] | wordr0[2];
603     w0[3] = wordl0[3] | wordr0[3];
604
605     u32x w1[4];
606
607     w1[0] = wordl1[0] | wordr1[0];
608     w1[1] = wordl1[1] | wordr1[1];
609     w1[2] = wordl1[2] | wordr1[2];
610     w1[3] = wordl1[3] | wordr1[3];
611
612     u32x w2[4];
613
614     w2[0] = wordl2[0] | wordr2[0];
615     w2[1] = wordl2[1] | wordr2[1];
616     w2[2] = wordl2[2] | wordr2[2];
617     w2[3] = wordl2[3] | wordr2[3];
618
619     u32x w3[4];
620
621     w3[0] = wordl3[0] | wordr3[0];
622     w3[1] = wordl3[1] | wordr3[1];
623     w3[2] = wordl3[2] | wordr3[2];
624     w3[3] = wordl3[3] | wordr3[3];
625
626     /**
627      * pads
628      */
629
630     u32x w0_t[4];
631
632     w0_t[0] = w0[0];
633     w0_t[1] = w0[1];
634     w0_t[2] = w0[2];
635     w0_t[3] = w0[3];
636
637     u32x w1_t[4];
638
639     w1_t[0] = w1[0];
640     w1_t[1] = w1[1];
641     w1_t[2] = w1[2];
642     w1_t[3] = w1[3];
643
644     u32x w2_t[4];
645
646     w2_t[0] = 0;
647     w2_t[1] = 0;
648     w2_t[2] = 0;
649     w2_t[3] = 0;
650
651     u32x w3_t[4];
652
653     w3_t[0] = 0;
654     w3_t[1] = 0;
655     w3_t[2] = 0;
656     w3_t[3] = 0;
657
658     u32x ipad[4];
659     u32x opad[4];
660
661     hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
662
663     w0_t[0] = salt_buf0[0];
664     w0_t[1] = salt_buf0[1];
665     w0_t[2] = salt_buf0[2];
666     w0_t[3] = salt_buf0[3];
667     w1_t[0] = salt_buf1[0];
668     w1_t[1] = salt_buf1[1];
669     w1_t[2] = salt_buf1[2];
670     w1_t[3] = salt_buf1[3];
671     w2_t[0] = salt_buf2[0];
672     w2_t[1] = salt_buf2[1];
673     w2_t[2] = salt_buf2[2];
674     w2_t[3] = salt_buf2[3];
675     w3_t[0] = salt_buf3[0];
676     w3_t[1] = salt_buf3[1];
677     w3_t[2] = (64 + salt_len) * 8;
678     w3_t[3] = 0;
679
680     u32x digest[4];
681
682     hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
683
684     const u32x r0 = digest[0];
685     const u32x r1 = digest[3];
686     const u32x r2 = digest[2];
687     const u32x r3 = digest[1];
688
689     #include VECT_COMPARE_S
690   }
691 }
692
693 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00050_s08 (__global pw_t *pws, __global gpu_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)
694 {
695 }
696
697 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00050_s16 (__global pw_t *pws, __global gpu_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)
698 {
699 }