Fix path to includes
[hashcat.git] / OpenCL / m05600_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _NETNTLMV2_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #define DGST_R0 0
12 #define DGST_R1 3
13 #define DGST_R2 2
14 #define DGST_R3 1
15
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19 #include "include/rp_gpu.h"
20 #include "rp.c"
21
22 #define COMPARE_S "OpenCL/check_single_comp4.c"
23 #define COMPARE_M "OpenCL/check_multi_comp4.c"
24
25 static void md4_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4])
26 {
27   u32 a = digest[0];
28   u32 b = digest[1];
29   u32 c = digest[2];
30   u32 d = digest[3];
31
32   u32 w0_t = w0[0];
33   u32 w1_t = w0[1];
34   u32 w2_t = w0[2];
35   u32 w3_t = w0[3];
36   u32 w4_t = w1[0];
37   u32 w5_t = w1[1];
38   u32 w6_t = w1[2];
39   u32 w7_t = w1[3];
40   u32 w8_t = w2[0];
41   u32 w9_t = w2[1];
42   u32 wa_t = w2[2];
43   u32 wb_t = w2[3];
44   u32 wc_t = w3[0];
45   u32 wd_t = w3[1];
46   u32 we_t = w3[2];
47   u32 wf_t = w3[3];
48
49   MD4_STEP (MD4_Fo, a, b, c, d, w0_t, MD4C00, MD4S00);
50   MD4_STEP (MD4_Fo, d, a, b, c, w1_t, MD4C00, MD4S01);
51   MD4_STEP (MD4_Fo, c, d, a, b, w2_t, MD4C00, MD4S02);
52   MD4_STEP (MD4_Fo, b, c, d, a, w3_t, MD4C00, MD4S03);
53   MD4_STEP (MD4_Fo, a, b, c, d, w4_t, MD4C00, MD4S00);
54   MD4_STEP (MD4_Fo, d, a, b, c, w5_t, MD4C00, MD4S01);
55   MD4_STEP (MD4_Fo, c, d, a, b, w6_t, MD4C00, MD4S02);
56   MD4_STEP (MD4_Fo, b, c, d, a, w7_t, MD4C00, MD4S03);
57   MD4_STEP (MD4_Fo, a, b, c, d, w8_t, MD4C00, MD4S00);
58   MD4_STEP (MD4_Fo, d, a, b, c, w9_t, MD4C00, MD4S01);
59   MD4_STEP (MD4_Fo, c, d, a, b, wa_t, MD4C00, MD4S02);
60   MD4_STEP (MD4_Fo, b, c, d, a, wb_t, MD4C00, MD4S03);
61   MD4_STEP (MD4_Fo, a, b, c, d, wc_t, MD4C00, MD4S00);
62   MD4_STEP (MD4_Fo, d, a, b, c, wd_t, MD4C00, MD4S01);
63   MD4_STEP (MD4_Fo, c, d, a, b, we_t, MD4C00, MD4S02);
64   MD4_STEP (MD4_Fo, b, c, d, a, wf_t, MD4C00, MD4S03);
65
66   MD4_STEP (MD4_Go, a, b, c, d, w0_t, MD4C01, MD4S10);
67   MD4_STEP (MD4_Go, d, a, b, c, w4_t, MD4C01, MD4S11);
68   MD4_STEP (MD4_Go, c, d, a, b, w8_t, MD4C01, MD4S12);
69   MD4_STEP (MD4_Go, b, c, d, a, wc_t, MD4C01, MD4S13);
70   MD4_STEP (MD4_Go, a, b, c, d, w1_t, MD4C01, MD4S10);
71   MD4_STEP (MD4_Go, d, a, b, c, w5_t, MD4C01, MD4S11);
72   MD4_STEP (MD4_Go, c, d, a, b, w9_t, MD4C01, MD4S12);
73   MD4_STEP (MD4_Go, b, c, d, a, wd_t, MD4C01, MD4S13);
74   MD4_STEP (MD4_Go, a, b, c, d, w2_t, MD4C01, MD4S10);
75   MD4_STEP (MD4_Go, d, a, b, c, w6_t, MD4C01, MD4S11);
76   MD4_STEP (MD4_Go, c, d, a, b, wa_t, MD4C01, MD4S12);
77   MD4_STEP (MD4_Go, b, c, d, a, we_t, MD4C01, MD4S13);
78   MD4_STEP (MD4_Go, a, b, c, d, w3_t, MD4C01, MD4S10);
79   MD4_STEP (MD4_Go, d, a, b, c, w7_t, MD4C01, MD4S11);
80   MD4_STEP (MD4_Go, c, d, a, b, wb_t, MD4C01, MD4S12);
81   MD4_STEP (MD4_Go, b, c, d, a, wf_t, MD4C01, MD4S13);
82
83   MD4_STEP (MD4_H , a, b, c, d, w0_t, MD4C02, MD4S20);
84   MD4_STEP (MD4_H , d, a, b, c, w8_t, MD4C02, MD4S21);
85   MD4_STEP (MD4_H , c, d, a, b, w4_t, MD4C02, MD4S22);
86   MD4_STEP (MD4_H , b, c, d, a, wc_t, MD4C02, MD4S23);
87   MD4_STEP (MD4_H , a, b, c, d, w2_t, MD4C02, MD4S20);
88   MD4_STEP (MD4_H , d, a, b, c, wa_t, MD4C02, MD4S21);
89   MD4_STEP (MD4_H , c, d, a, b, w6_t, MD4C02, MD4S22);
90   MD4_STEP (MD4_H , b, c, d, a, we_t, MD4C02, MD4S23);
91   MD4_STEP (MD4_H , a, b, c, d, w1_t, MD4C02, MD4S20);
92   MD4_STEP (MD4_H , d, a, b, c, w9_t, MD4C02, MD4S21);
93   MD4_STEP (MD4_H , c, d, a, b, w5_t, MD4C02, MD4S22);
94   MD4_STEP (MD4_H , b, c, d, a, wd_t, MD4C02, MD4S23);
95   MD4_STEP (MD4_H , a, b, c, d, w3_t, MD4C02, MD4S20);
96   MD4_STEP (MD4_H , d, a, b, c, wb_t, MD4C02, MD4S21);
97   MD4_STEP (MD4_H , c, d, a, b, w7_t, MD4C02, MD4S22);
98   MD4_STEP (MD4_H , b, c, d, a, wf_t, MD4C02, MD4S23);
99
100   digest[0] += a;
101   digest[1] += b;
102   digest[2] += c;
103   digest[3] += d;
104 }
105
106 static void md5_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[4])
107 {
108   u32 a = digest[0];
109   u32 b = digest[1];
110   u32 c = digest[2];
111   u32 d = digest[3];
112
113   u32 w0_t = w0[0];
114   u32 w1_t = w0[1];
115   u32 w2_t = w0[2];
116   u32 w3_t = w0[3];
117   u32 w4_t = w1[0];
118   u32 w5_t = w1[1];
119   u32 w6_t = w1[2];
120   u32 w7_t = w1[3];
121   u32 w8_t = w2[0];
122   u32 w9_t = w2[1];
123   u32 wa_t = w2[2];
124   u32 wb_t = w2[3];
125   u32 wc_t = w3[0];
126   u32 wd_t = w3[1];
127   u32 we_t = w3[2];
128   u32 wf_t = w3[3];
129
130   MD5_STEP (MD5_Fo, a, b, c, d, w0_t, MD5C00, MD5S00);
131   MD5_STEP (MD5_Fo, d, a, b, c, w1_t, MD5C01, MD5S01);
132   MD5_STEP (MD5_Fo, c, d, a, b, w2_t, MD5C02, MD5S02);
133   MD5_STEP (MD5_Fo, b, c, d, a, w3_t, MD5C03, MD5S03);
134   MD5_STEP (MD5_Fo, a, b, c, d, w4_t, MD5C04, MD5S00);
135   MD5_STEP (MD5_Fo, d, a, b, c, w5_t, MD5C05, MD5S01);
136   MD5_STEP (MD5_Fo, c, d, a, b, w6_t, MD5C06, MD5S02);
137   MD5_STEP (MD5_Fo, b, c, d, a, w7_t, MD5C07, MD5S03);
138   MD5_STEP (MD5_Fo, a, b, c, d, w8_t, MD5C08, MD5S00);
139   MD5_STEP (MD5_Fo, d, a, b, c, w9_t, MD5C09, MD5S01);
140   MD5_STEP (MD5_Fo, c, d, a, b, wa_t, MD5C0a, MD5S02);
141   MD5_STEP (MD5_Fo, b, c, d, a, wb_t, MD5C0b, MD5S03);
142   MD5_STEP (MD5_Fo, a, b, c, d, wc_t, MD5C0c, MD5S00);
143   MD5_STEP (MD5_Fo, d, a, b, c, wd_t, MD5C0d, MD5S01);
144   MD5_STEP (MD5_Fo, c, d, a, b, we_t, MD5C0e, MD5S02);
145   MD5_STEP (MD5_Fo, b, c, d, a, wf_t, MD5C0f, MD5S03);
146
147   MD5_STEP (MD5_Go, a, b, c, d, w1_t, MD5C10, MD5S10);
148   MD5_STEP (MD5_Go, d, a, b, c, w6_t, MD5C11, MD5S11);
149   MD5_STEP (MD5_Go, c, d, a, b, wb_t, MD5C12, MD5S12);
150   MD5_STEP (MD5_Go, b, c, d, a, w0_t, MD5C13, MD5S13);
151   MD5_STEP (MD5_Go, a, b, c, d, w5_t, MD5C14, MD5S10);
152   MD5_STEP (MD5_Go, d, a, b, c, wa_t, MD5C15, MD5S11);
153   MD5_STEP (MD5_Go, c, d, a, b, wf_t, MD5C16, MD5S12);
154   MD5_STEP (MD5_Go, b, c, d, a, w4_t, MD5C17, MD5S13);
155   MD5_STEP (MD5_Go, a, b, c, d, w9_t, MD5C18, MD5S10);
156   MD5_STEP (MD5_Go, d, a, b, c, we_t, MD5C19, MD5S11);
157   MD5_STEP (MD5_Go, c, d, a, b, w3_t, MD5C1a, MD5S12);
158   MD5_STEP (MD5_Go, b, c, d, a, w8_t, MD5C1b, MD5S13);
159   MD5_STEP (MD5_Go, a, b, c, d, wd_t, MD5C1c, MD5S10);
160   MD5_STEP (MD5_Go, d, a, b, c, w2_t, MD5C1d, MD5S11);
161   MD5_STEP (MD5_Go, c, d, a, b, w7_t, MD5C1e, MD5S12);
162   MD5_STEP (MD5_Go, b, c, d, a, wc_t, MD5C1f, MD5S13);
163
164   MD5_STEP (MD5_H , a, b, c, d, w5_t, MD5C20, MD5S20);
165   MD5_STEP (MD5_H , d, a, b, c, w8_t, MD5C21, MD5S21);
166   MD5_STEP (MD5_H , c, d, a, b, wb_t, MD5C22, MD5S22);
167   MD5_STEP (MD5_H , b, c, d, a, we_t, MD5C23, MD5S23);
168   MD5_STEP (MD5_H , a, b, c, d, w1_t, MD5C24, MD5S20);
169   MD5_STEP (MD5_H , d, a, b, c, w4_t, MD5C25, MD5S21);
170   MD5_STEP (MD5_H , c, d, a, b, w7_t, MD5C26, MD5S22);
171   MD5_STEP (MD5_H , b, c, d, a, wa_t, MD5C27, MD5S23);
172   MD5_STEP (MD5_H , a, b, c, d, wd_t, MD5C28, MD5S20);
173   MD5_STEP (MD5_H , d, a, b, c, w0_t, MD5C29, MD5S21);
174   MD5_STEP (MD5_H , c, d, a, b, w3_t, MD5C2a, MD5S22);
175   MD5_STEP (MD5_H , b, c, d, a, w6_t, MD5C2b, MD5S23);
176   MD5_STEP (MD5_H , a, b, c, d, w9_t, MD5C2c, MD5S20);
177   MD5_STEP (MD5_H , d, a, b, c, wc_t, MD5C2d, MD5S21);
178   MD5_STEP (MD5_H , c, d, a, b, wf_t, MD5C2e, MD5S22);
179   MD5_STEP (MD5_H , b, c, d, a, w2_t, MD5C2f, MD5S23);
180
181   MD5_STEP (MD5_I , a, b, c, d, w0_t, MD5C30, MD5S30);
182   MD5_STEP (MD5_I , d, a, b, c, w7_t, MD5C31, MD5S31);
183   MD5_STEP (MD5_I , c, d, a, b, we_t, MD5C32, MD5S32);
184   MD5_STEP (MD5_I , b, c, d, a, w5_t, MD5C33, MD5S33);
185   MD5_STEP (MD5_I , a, b, c, d, wc_t, MD5C34, MD5S30);
186   MD5_STEP (MD5_I , d, a, b, c, w3_t, MD5C35, MD5S31);
187   MD5_STEP (MD5_I , c, d, a, b, wa_t, MD5C36, MD5S32);
188   MD5_STEP (MD5_I , b, c, d, a, w1_t, MD5C37, MD5S33);
189   MD5_STEP (MD5_I , a, b, c, d, w8_t, MD5C38, MD5S30);
190   MD5_STEP (MD5_I , d, a, b, c, wf_t, MD5C39, MD5S31);
191   MD5_STEP (MD5_I , c, d, a, b, w6_t, MD5C3a, MD5S32);
192   MD5_STEP (MD5_I , b, c, d, a, wd_t, MD5C3b, MD5S33);
193   MD5_STEP (MD5_I , a, b, c, d, w4_t, MD5C3c, MD5S30);
194   MD5_STEP (MD5_I , d, a, b, c, wb_t, MD5C3d, MD5S31);
195   MD5_STEP (MD5_I , c, d, a, b, w2_t, MD5C3e, MD5S32);
196   MD5_STEP (MD5_I , b, c, d, a, w9_t, MD5C3f, MD5S33);
197
198   digest[0] += a;
199   digest[1] += b;
200   digest[2] += c;
201   digest[3] += d;
202 }
203
204 static void hmac_md5_pad (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[4], u32 opad[4])
205 {
206   w0[0] = w0[0] ^ 0x36363636;
207   w0[1] = w0[1] ^ 0x36363636;
208   w0[2] = w0[2] ^ 0x36363636;
209   w0[3] = w0[3] ^ 0x36363636;
210   w1[0] = w1[0] ^ 0x36363636;
211   w1[1] = w1[1] ^ 0x36363636;
212   w1[2] = w1[2] ^ 0x36363636;
213   w1[3] = w1[3] ^ 0x36363636;
214   w2[0] = w2[0] ^ 0x36363636;
215   w2[1] = w2[1] ^ 0x36363636;
216   w2[2] = w2[2] ^ 0x36363636;
217   w2[3] = w2[3] ^ 0x36363636;
218   w3[0] = w3[0] ^ 0x36363636;
219   w3[1] = w3[1] ^ 0x36363636;
220   w3[2] = w3[2] ^ 0x36363636;
221   w3[3] = w3[3] ^ 0x36363636;
222
223   ipad[0] = MD5M_A;
224   ipad[1] = MD5M_B;
225   ipad[2] = MD5M_C;
226   ipad[3] = MD5M_D;
227
228   md5_transform (w0, w1, w2, w3, ipad);
229
230   w0[0] = w0[0] ^ 0x6a6a6a6a;
231   w0[1] = w0[1] ^ 0x6a6a6a6a;
232   w0[2] = w0[2] ^ 0x6a6a6a6a;
233   w0[3] = w0[3] ^ 0x6a6a6a6a;
234   w1[0] = w1[0] ^ 0x6a6a6a6a;
235   w1[1] = w1[1] ^ 0x6a6a6a6a;
236   w1[2] = w1[2] ^ 0x6a6a6a6a;
237   w1[3] = w1[3] ^ 0x6a6a6a6a;
238   w2[0] = w2[0] ^ 0x6a6a6a6a;
239   w2[1] = w2[1] ^ 0x6a6a6a6a;
240   w2[2] = w2[2] ^ 0x6a6a6a6a;
241   w2[3] = w2[3] ^ 0x6a6a6a6a;
242   w3[0] = w3[0] ^ 0x6a6a6a6a;
243   w3[1] = w3[1] ^ 0x6a6a6a6a;
244   w3[2] = w3[2] ^ 0x6a6a6a6a;
245   w3[3] = w3[3] ^ 0x6a6a6a6a;
246
247   opad[0] = MD5M_A;
248   opad[1] = MD5M_B;
249   opad[2] = MD5M_C;
250   opad[3] = MD5M_D;
251
252   md5_transform (w0, w1, w2, w3, opad);
253 }
254
255 static void hmac_md5_run (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[4], u32 opad[4], u32 digest[4])
256 {
257   digest[0] = ipad[0];
258   digest[1] = ipad[1];
259   digest[2] = ipad[2];
260   digest[3] = ipad[3];
261
262   md5_transform (w0, w1, w2, w3, digest);
263
264   w0[0] = digest[0];
265   w0[1] = digest[1];
266   w0[2] = digest[2];
267   w0[3] = digest[3];
268   w1[0] = 0x80;
269   w1[1] = 0;
270   w1[2] = 0;
271   w1[3] = 0;
272   w2[0] = 0;
273   w2[1] = 0;
274   w2[2] = 0;
275   w2[3] = 0;
276   w3[0] = 0;
277   w3[1] = 0;
278   w3[2] = (64 + 16) * 8;
279   w3[3] = 0;
280
281   digest[0] = opad[0];
282   digest[1] = opad[1];
283   digest[2] = opad[2];
284   digest[3] = opad[3];
285
286   md5_transform (w0, w1, w2, w3, digest);
287 }
288
289 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05600_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 netntlm_t *netntlm_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
290 {
291   /**
292    * modifier
293    */
294
295   const u32 lid = get_local_id (0);
296
297   /**
298    * base
299    */
300
301   const u32 gid = get_global_id (0);
302
303   u32 pw_buf0[4];
304
305   pw_buf0[0] = pws[gid].i[ 0];
306   pw_buf0[1] = pws[gid].i[ 1];
307   pw_buf0[2] = pws[gid].i[ 2];
308   pw_buf0[3] = pws[gid].i[ 3];
309
310   u32 pw_buf1[4];
311
312   pw_buf1[0] = pws[gid].i[ 4];
313   pw_buf1[1] = pws[gid].i[ 5];
314   pw_buf1[2] = pws[gid].i[ 6];
315   pw_buf1[3] = pws[gid].i[ 7];
316
317   const u32 pw_len = pws[gid].pw_len;
318
319   /**
320    * salt
321    */
322
323   __local u32 s_userdomain_buf[64];
324   __local u32 s_chall_buf[256];
325
326   const u32 userdomain_len = netntlm_bufs[salt_pos].user_len
327                             + netntlm_bufs[salt_pos].domain_len;
328
329   const u32 chall_len = netntlm_bufs[salt_pos].srvchall_len
330                        + netntlm_bufs[salt_pos].clichall_len;
331
332   if (lid < 64)
333   {
334     s_userdomain_buf[lid] = netntlm_bufs[salt_pos].userdomain_buf[lid];
335   }
336
337   const u32 lid4 = lid * 4;
338
339   s_chall_buf[lid4 + 0] = netntlm_bufs[salt_pos].chall_buf[lid4 + 0];
340   s_chall_buf[lid4 + 1] = netntlm_bufs[salt_pos].chall_buf[lid4 + 1];
341   s_chall_buf[lid4 + 2] = netntlm_bufs[salt_pos].chall_buf[lid4 + 2];
342   s_chall_buf[lid4 + 3] = netntlm_bufs[salt_pos].chall_buf[lid4 + 3];
343
344   barrier (CLK_LOCAL_MEM_FENCE);
345
346   if (gid >= gid_max) return;
347
348   /**
349    * loop
350    */
351
352   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
353   {
354     u32 w0[4];
355
356     w0[0] = pw_buf0[0];
357     w0[1] = pw_buf0[1];
358     w0[2] = pw_buf0[2];
359     w0[3] = pw_buf0[3];
360
361     u32 w1[4];
362
363     w1[0] = pw_buf1[0];
364     w1[1] = pw_buf1[1];
365     w1[2] = pw_buf1[2];
366     w1[3] = pw_buf1[3];
367
368     u32 w2[4];
369
370     w2[0] = 0;
371     w2[1] = 0;
372     w2[2] = 0;
373     w2[3] = 0;
374
375     u32 w3[4];
376
377     w3[0] = 0;
378     w3[1] = 0;
379     w3[2] = 0;
380     w3[3] = 0;
381
382     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
383
384     append_0x80_2x4 (w0, w1, out_len);
385
386     u32 w0_t[4];
387     u32 w1_t[4];
388     u32 w2_t[4];
389     u32 w3_t[4];
390
391     make_unicode (w0, w0_t, w1_t);
392     make_unicode (w1, w2_t, w3_t);
393
394     w3_t[2] = out_len * 8 * 2;
395
396     u32 digest[4];
397
398     digest[0] = MD4M_A;
399     digest[1] = MD4M_B;
400     digest[2] = MD4M_C;
401     digest[3] = MD4M_D;
402
403     md4_transform (w0_t, w1_t, w2_t, w3_t, digest);
404
405     w0_t[0] = digest[0];
406     w0_t[1] = digest[1];
407     w0_t[2] = digest[2];
408     w0_t[3] = digest[3];
409     w1_t[0] = 0;
410     w1_t[1] = 0;
411     w1_t[2] = 0;
412     w1_t[3] = 0;
413     w2_t[0] = 0;
414     w2_t[1] = 0;
415     w2_t[2] = 0;
416     w2_t[3] = 0;
417     w3_t[0] = 0;
418     w3_t[1] = 0;
419     w3_t[2] = 0;
420     w3_t[3] = 0;
421
422     digest[0] = MD5M_A;
423     digest[1] = MD5M_B;
424     digest[2] = MD5M_C;
425     digest[3] = MD5M_D;
426
427     u32 ipad[4];
428     u32 opad[4];
429
430     hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
431
432     int left;
433     int off;
434
435     for (left = userdomain_len, off = 0; left >= 56; left -= 64, off += 16)
436     {
437       w0_t[0] = s_userdomain_buf[off +  0];
438       w0_t[1] = s_userdomain_buf[off +  1];
439       w0_t[2] = s_userdomain_buf[off +  2];
440       w0_t[3] = s_userdomain_buf[off +  3];
441       w1_t[0] = s_userdomain_buf[off +  4];
442       w1_t[1] = s_userdomain_buf[off +  5];
443       w1_t[2] = s_userdomain_buf[off +  6];
444       w1_t[3] = s_userdomain_buf[off +  7];
445       w2_t[0] = s_userdomain_buf[off +  8];
446       w2_t[1] = s_userdomain_buf[off +  9];
447       w2_t[2] = s_userdomain_buf[off + 10];
448       w2_t[3] = s_userdomain_buf[off + 11];
449       w3_t[0] = s_userdomain_buf[off + 12];
450       w3_t[1] = s_userdomain_buf[off + 13];
451       w3_t[2] = s_userdomain_buf[off + 14];
452       w3_t[3] = s_userdomain_buf[off + 15];
453
454       md5_transform (w0_t, w1_t, w2_t, w3_t, ipad);
455     }
456
457     w0_t[0] = s_userdomain_buf[off +  0];
458     w0_t[1] = s_userdomain_buf[off +  1];
459     w0_t[2] = s_userdomain_buf[off +  2];
460     w0_t[3] = s_userdomain_buf[off +  3];
461     w1_t[0] = s_userdomain_buf[off +  4];
462     w1_t[1] = s_userdomain_buf[off +  5];
463     w1_t[2] = s_userdomain_buf[off +  6];
464     w1_t[3] = s_userdomain_buf[off +  7];
465     w2_t[0] = s_userdomain_buf[off +  8];
466     w2_t[1] = s_userdomain_buf[off +  9];
467     w2_t[2] = s_userdomain_buf[off + 10];
468     w2_t[3] = s_userdomain_buf[off + 11];
469     w3_t[0] = s_userdomain_buf[off + 12];
470     w3_t[1] = s_userdomain_buf[off + 13];
471     w3_t[2] = (64 + userdomain_len) * 8;
472     w3_t[3] = 0;
473
474     hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
475
476     w0_t[0] = digest[0];
477     w0_t[1] = digest[1];
478     w0_t[2] = digest[2];
479     w0_t[3] = digest[3];
480     w1_t[0] = 0;
481     w1_t[1] = 0;
482     w1_t[2] = 0;
483     w1_t[3] = 0;
484     w2_t[0] = 0;
485     w2_t[1] = 0;
486     w2_t[2] = 0;
487     w2_t[3] = 0;
488     w3_t[0] = 0;
489     w3_t[1] = 0;
490     w3_t[2] = 0;
491     w3_t[3] = 0;
492
493     digest[0] = MD5M_A;
494     digest[1] = MD5M_B;
495     digest[2] = MD5M_C;
496     digest[3] = MD5M_D;
497
498     hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
499
500     for (left = chall_len, off = 0; left >= 56; left -= 64, off += 16)
501     {
502       w0_t[0] = s_chall_buf[off +  0];
503       w0_t[1] = s_chall_buf[off +  1];
504       w0_t[2] = s_chall_buf[off +  2];
505       w0_t[3] = s_chall_buf[off +  3];
506       w1_t[0] = s_chall_buf[off +  4];
507       w1_t[1] = s_chall_buf[off +  5];
508       w1_t[2] = s_chall_buf[off +  6];
509       w1_t[3] = s_chall_buf[off +  7];
510       w2_t[0] = s_chall_buf[off +  8];
511       w2_t[1] = s_chall_buf[off +  9];
512       w2_t[2] = s_chall_buf[off + 10];
513       w2_t[3] = s_chall_buf[off + 11];
514       w3_t[0] = s_chall_buf[off + 12];
515       w3_t[1] = s_chall_buf[off + 13];
516       w3_t[2] = s_chall_buf[off + 14];
517       w3_t[3] = s_chall_buf[off + 15];
518
519       md5_transform (w0_t, w1_t, w2_t, w3_t, ipad);
520     }
521
522     w0_t[0] = s_chall_buf[off +  0];
523     w0_t[1] = s_chall_buf[off +  1];
524     w0_t[2] = s_chall_buf[off +  2];
525     w0_t[3] = s_chall_buf[off +  3];
526     w1_t[0] = s_chall_buf[off +  4];
527     w1_t[1] = s_chall_buf[off +  5];
528     w1_t[2] = s_chall_buf[off +  6];
529     w1_t[3] = s_chall_buf[off +  7];
530     w2_t[0] = s_chall_buf[off +  8];
531     w2_t[1] = s_chall_buf[off +  9];
532     w2_t[2] = s_chall_buf[off + 10];
533     w2_t[3] = s_chall_buf[off + 11];
534     w3_t[0] = s_chall_buf[off + 12];
535     w3_t[1] = s_chall_buf[off + 13];
536     w3_t[2] = (64 + chall_len) * 8;
537     w3_t[3] = 0;
538
539     hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
540
541     const u32 r0 = digest[0];
542     const u32 r1 = digest[3];
543     const u32 r2 = digest[2];
544     const u32 r3 = digest[1];
545
546     #include COMPARE_M
547   }
548 }
549
550 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05600_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 netntlm_t *netntlm_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)
551 {
552 }
553
554 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05600_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 netntlm_t *netntlm_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)
555 {
556 }
557
558 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05600_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 netntlm_t *netntlm_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
559 {
560   /**
561    * modifier
562    */
563
564   const u32 lid = get_local_id (0);
565
566   /**
567    * base
568    */
569
570   const u32 gid = get_global_id (0);
571
572   u32 pw_buf0[4];
573
574   pw_buf0[0] = pws[gid].i[ 0];
575   pw_buf0[1] = pws[gid].i[ 1];
576   pw_buf0[2] = pws[gid].i[ 2];
577   pw_buf0[3] = pws[gid].i[ 3];
578
579   u32 pw_buf1[4];
580
581   pw_buf1[0] = pws[gid].i[ 4];
582   pw_buf1[1] = pws[gid].i[ 5];
583   pw_buf1[2] = pws[gid].i[ 6];
584   pw_buf1[3] = pws[gid].i[ 7];
585
586   const u32 pw_len = pws[gid].pw_len;
587
588   /**
589    * salt
590    */
591
592   __local u32 s_userdomain_buf[64];
593   __local u32 s_chall_buf[256];
594
595   const u32 userdomain_len = netntlm_bufs[salt_pos].user_len
596                             + netntlm_bufs[salt_pos].domain_len;
597
598   const u32 chall_len = netntlm_bufs[salt_pos].srvchall_len
599                        + netntlm_bufs[salt_pos].clichall_len;
600
601   if (lid < 64)
602   {
603     s_userdomain_buf[lid] = netntlm_bufs[salt_pos].userdomain_buf[lid];
604   }
605
606   const u32 lid4 = lid * 4;
607
608   s_chall_buf[lid4 + 0] = netntlm_bufs[salt_pos].chall_buf[lid4 + 0];
609   s_chall_buf[lid4 + 1] = netntlm_bufs[salt_pos].chall_buf[lid4 + 1];
610   s_chall_buf[lid4 + 2] = netntlm_bufs[salt_pos].chall_buf[lid4 + 2];
611   s_chall_buf[lid4 + 3] = netntlm_bufs[salt_pos].chall_buf[lid4 + 3];
612
613   barrier (CLK_LOCAL_MEM_FENCE);
614
615   if (gid >= gid_max) return;
616
617   /**
618    * digest
619    */
620
621   const u32 search[4] =
622   {
623     digests_buf[digests_offset].digest_buf[DGST_R0],
624     digests_buf[digests_offset].digest_buf[DGST_R1],
625     digests_buf[digests_offset].digest_buf[DGST_R2],
626     digests_buf[digests_offset].digest_buf[DGST_R3]
627   };
628
629   /**
630    * loop
631    */
632
633   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
634   {
635     u32 w0[4];
636
637     w0[0] = pw_buf0[0];
638     w0[1] = pw_buf0[1];
639     w0[2] = pw_buf0[2];
640     w0[3] = pw_buf0[3];
641
642     u32 w1[4];
643
644     w1[0] = pw_buf1[0];
645     w1[1] = pw_buf1[1];
646     w1[2] = pw_buf1[2];
647     w1[3] = pw_buf1[3];
648
649     u32 w2[4];
650
651     w2[0] = 0;
652     w2[1] = 0;
653     w2[2] = 0;
654     w2[3] = 0;
655
656     u32 w3[4];
657
658     w3[0] = 0;
659     w3[1] = 0;
660     w3[2] = 0;
661     w3[3] = 0;
662
663     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
664
665     append_0x80_2x4 (w0, w1, out_len);
666
667     u32 w0_t[4];
668     u32 w1_t[4];
669     u32 w2_t[4];
670     u32 w3_t[4];
671
672     make_unicode (w0, w0_t, w1_t);
673     make_unicode (w1, w2_t, w3_t);
674
675     w3_t[2] = out_len * 8 * 2;
676
677     u32 digest[4];
678
679     digest[0] = MD4M_A;
680     digest[1] = MD4M_B;
681     digest[2] = MD4M_C;
682     digest[3] = MD4M_D;
683
684     md4_transform (w0_t, w1_t, w2_t, w3_t, digest);
685
686     w0_t[0] = digest[0];
687     w0_t[1] = digest[1];
688     w0_t[2] = digest[2];
689     w0_t[3] = digest[3];
690     w1_t[0] = 0;
691     w1_t[1] = 0;
692     w1_t[2] = 0;
693     w1_t[3] = 0;
694     w2_t[0] = 0;
695     w2_t[1] = 0;
696     w2_t[2] = 0;
697     w2_t[3] = 0;
698     w3_t[0] = 0;
699     w3_t[1] = 0;
700     w3_t[2] = 0;
701     w3_t[3] = 0;
702
703     digest[0] = MD5M_A;
704     digest[1] = MD5M_B;
705     digest[2] = MD5M_C;
706     digest[3] = MD5M_D;
707
708     u32 ipad[4];
709     u32 opad[4];
710
711     hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
712
713     int left;
714     int off;
715
716     for (left = userdomain_len, off = 0; left >= 56; left -= 64, off += 16)
717     {
718       w0_t[0] = s_userdomain_buf[off +  0];
719       w0_t[1] = s_userdomain_buf[off +  1];
720       w0_t[2] = s_userdomain_buf[off +  2];
721       w0_t[3] = s_userdomain_buf[off +  3];
722       w1_t[0] = s_userdomain_buf[off +  4];
723       w1_t[1] = s_userdomain_buf[off +  5];
724       w1_t[2] = s_userdomain_buf[off +  6];
725       w1_t[3] = s_userdomain_buf[off +  7];
726       w2_t[0] = s_userdomain_buf[off +  8];
727       w2_t[1] = s_userdomain_buf[off +  9];
728       w2_t[2] = s_userdomain_buf[off + 10];
729       w2_t[3] = s_userdomain_buf[off + 11];
730       w3_t[0] = s_userdomain_buf[off + 12];
731       w3_t[1] = s_userdomain_buf[off + 13];
732       w3_t[2] = s_userdomain_buf[off + 14];
733       w3_t[3] = s_userdomain_buf[off + 15];
734
735       md5_transform (w0_t, w1_t, w2_t, w3_t, ipad);
736     }
737
738     w0_t[0] = s_userdomain_buf[off +  0];
739     w0_t[1] = s_userdomain_buf[off +  1];
740     w0_t[2] = s_userdomain_buf[off +  2];
741     w0_t[3] = s_userdomain_buf[off +  3];
742     w1_t[0] = s_userdomain_buf[off +  4];
743     w1_t[1] = s_userdomain_buf[off +  5];
744     w1_t[2] = s_userdomain_buf[off +  6];
745     w1_t[3] = s_userdomain_buf[off +  7];
746     w2_t[0] = s_userdomain_buf[off +  8];
747     w2_t[1] = s_userdomain_buf[off +  9];
748     w2_t[2] = s_userdomain_buf[off + 10];
749     w2_t[3] = s_userdomain_buf[off + 11];
750     w3_t[0] = s_userdomain_buf[off + 12];
751     w3_t[1] = s_userdomain_buf[off + 13];
752     w3_t[2] = (64 + userdomain_len) * 8;
753     w3_t[3] = 0;
754
755     hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
756
757     w0_t[0] = digest[0];
758     w0_t[1] = digest[1];
759     w0_t[2] = digest[2];
760     w0_t[3] = digest[3];
761     w1_t[0] = 0;
762     w1_t[1] = 0;
763     w1_t[2] = 0;
764     w1_t[3] = 0;
765     w2_t[0] = 0;
766     w2_t[1] = 0;
767     w2_t[2] = 0;
768     w2_t[3] = 0;
769     w3_t[0] = 0;
770     w3_t[1] = 0;
771     w3_t[2] = 0;
772     w3_t[3] = 0;
773
774     digest[0] = MD5M_A;
775     digest[1] = MD5M_B;
776     digest[2] = MD5M_C;
777     digest[3] = MD5M_D;
778
779     hmac_md5_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
780
781     for (left = chall_len, off = 0; left >= 56; left -= 64, off += 16)
782     {
783       w0_t[0] = s_chall_buf[off +  0];
784       w0_t[1] = s_chall_buf[off +  1];
785       w0_t[2] = s_chall_buf[off +  2];
786       w0_t[3] = s_chall_buf[off +  3];
787       w1_t[0] = s_chall_buf[off +  4];
788       w1_t[1] = s_chall_buf[off +  5];
789       w1_t[2] = s_chall_buf[off +  6];
790       w1_t[3] = s_chall_buf[off +  7];
791       w2_t[0] = s_chall_buf[off +  8];
792       w2_t[1] = s_chall_buf[off +  9];
793       w2_t[2] = s_chall_buf[off + 10];
794       w2_t[3] = s_chall_buf[off + 11];
795       w3_t[0] = s_chall_buf[off + 12];
796       w3_t[1] = s_chall_buf[off + 13];
797       w3_t[2] = s_chall_buf[off + 14];
798       w3_t[3] = s_chall_buf[off + 15];
799
800       md5_transform (w0_t, w1_t, w2_t, w3_t, ipad);
801     }
802
803     w0_t[0] = s_chall_buf[off +  0];
804     w0_t[1] = s_chall_buf[off +  1];
805     w0_t[2] = s_chall_buf[off +  2];
806     w0_t[3] = s_chall_buf[off +  3];
807     w1_t[0] = s_chall_buf[off +  4];
808     w1_t[1] = s_chall_buf[off +  5];
809     w1_t[2] = s_chall_buf[off +  6];
810     w1_t[3] = s_chall_buf[off +  7];
811     w2_t[0] = s_chall_buf[off +  8];
812     w2_t[1] = s_chall_buf[off +  9];
813     w2_t[2] = s_chall_buf[off + 10];
814     w2_t[3] = s_chall_buf[off + 11];
815     w3_t[0] = s_chall_buf[off + 12];
816     w3_t[1] = s_chall_buf[off + 13];
817     w3_t[2] = (64 + chall_len) * 8;
818     w3_t[3] = 0;
819
820     hmac_md5_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
821
822     const u32 r0 = digest[0];
823     const u32 r1 = digest[3];
824     const u32 r2 = digest[2];
825     const u32 r3 = digest[1];
826
827     #include COMPARE_S
828   }
829 }
830
831 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05600_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 netntlm_t *netntlm_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)
832 {
833 }
834
835 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m05600_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 netntlm_t *netntlm_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)
836 {
837 }