Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / OpenCL / m09900_a1.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _MD5_
7
8 #define NEW_SIMD_CODE
9
10 #include "inc_vendor.cl"
11 #include "inc_hash_constants.h"
12 #include "inc_hash_functions.cl"
13 #include "inc_types.cl"
14 #include "inc_common.cl"
15 #include "inc_simd.cl"
16
17 __kernel void m09900_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)
18 {
19   /**
20    * modifier
21    */
22
23   const u32 lid = get_local_id (0);
24
25   /**
26    * base
27    */
28
29   const u32 gid = get_global_id (0);
30
31   if (gid >= gid_max) return;
32
33   u32 pw_buf0[4];
34   u32 pw_buf1[4];
35
36   pw_buf0[0] = pws[gid].i[0];
37   pw_buf0[1] = pws[gid].i[1];
38   pw_buf0[2] = pws[gid].i[2];
39   pw_buf0[3] = pws[gid].i[3];
40   pw_buf1[0] = pws[gid].i[4];
41   pw_buf1[1] = pws[gid].i[5];
42   pw_buf1[2] = pws[gid].i[6];
43   pw_buf1[3] = pws[gid].i[7];
44
45   const u32 pw_l_len = pws[gid].pw_len;
46
47   /**
48    * loop
49    */
50
51   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
52   {
53     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
54
55     const u32x pw_len = pw_l_len + pw_r_len;
56
57     /**
58      * concat password candidate
59      */
60
61     u32x wordl0[4] = { 0 };
62     u32x wordl1[4] = { 0 };
63     u32x wordl2[4] = { 0 };
64     u32x wordl3[4] = { 0 };
65
66     wordl0[0] = pw_buf0[0];
67     wordl0[1] = pw_buf0[1];
68     wordl0[2] = pw_buf0[2];
69     wordl0[3] = pw_buf0[3];
70     wordl1[0] = pw_buf1[0];
71     wordl1[1] = pw_buf1[1];
72     wordl1[2] = pw_buf1[2];
73     wordl1[3] = pw_buf1[3];
74
75     u32x wordr0[4] = { 0 };
76     u32x wordr1[4] = { 0 };
77     u32x wordr2[4] = { 0 };
78     u32x wordr3[4] = { 0 };
79
80     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
81     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
82     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
83     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
84     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
85     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
86     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
87     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
88
89     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
90     {
91       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
92     }
93     else
94     {
95       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
96     }
97
98     u32x w0[4];
99     u32x w1[4];
100     u32x w2[4];
101     u32x w3[4];
102
103     w0[0] = wordl0[0] | wordr0[0];
104     w0[1] = wordl0[1] | wordr0[1];
105     w0[2] = wordl0[2] | wordr0[2];
106     w0[3] = wordl0[3] | wordr0[3];
107     w1[0] = wordl1[0] | wordr1[0];
108     w1[1] = wordl1[1] | wordr1[1];
109     w1[2] = wordl1[2] | wordr1[2];
110     w1[3] = wordl1[3] | wordr1[3];
111     w2[0] = wordl2[0] | wordr2[0];
112     w2[1] = wordl2[1] | wordr2[1];
113     w2[2] = wordl2[2] | wordr2[2];
114     w2[3] = wordl2[3] | wordr2[3];
115     w3[0] = wordl3[0] | wordr3[0];
116     w3[1] = wordl3[1] | wordr3[1];
117     w3[2] = wordl3[2] | wordr3[2];
118     w3[3] = wordl3[3] | wordr3[3];
119
120     /**
121      * md5
122      */
123
124     u32x a = MD5M_A;
125     u32x b = MD5M_B;
126     u32x c = MD5M_C;
127     u32x d = MD5M_D;
128
129     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
130     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
131     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
132     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
133     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
134     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
135     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
136     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
137     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
138     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
139     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
140     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
141     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
142     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
143     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
144     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
145
146     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
147     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
148     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
149     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
150     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
151     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
152     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
153     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
154     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
155     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
156     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
157     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
158     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
159     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
160     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
161     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
162
163     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
164     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
165     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
166     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
167     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
168     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
169     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
170     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
171     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
172     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
173     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
174     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
175     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
176     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
177     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
178     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
179
180     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
181     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
182     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
183     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
184     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
185     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
186     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
187     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
188     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
189     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
190     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
191     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
192     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
193     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
194     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
195     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
196
197     a += MD5M_A;
198     b += MD5M_B;
199     c += MD5M_C;
200     d += MD5M_D;
201
202     u32x r_a = a;
203     u32x r_b = b;
204     u32x r_c = c;
205     u32x r_d = d;
206
207     w0[0] = 0;
208     w0[1] = 0;
209     w0[2] = 0;
210     w0[3] = 0;
211     w1[0] = 0;
212     w1[1] = 0;
213     w1[2] = 0;
214     w1[3] = 0;
215     w2[0] = 0;
216     w2[1] = 0x80;
217     w2[2] = 0;
218     w2[3] = 0;
219     w3[0] = 0;
220     w3[1] = 0;
221     w3[2] = 100 * 8;
222     w3[3] = 0;
223
224     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
225     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
226     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
227     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
228     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
229     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
230     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
231     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
232     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
233     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
234     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
235     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
236     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
237     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
238     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
239     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
240
241     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
242     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
243     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
244     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
245     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
246     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
247     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
248     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
249     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
250     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
251     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
252     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
253     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
254     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
255     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
256     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
257
258     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
259     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
260     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
261     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
262     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
263     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
264     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
265     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
266     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
267     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
268     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
269     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
270     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
271     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
272     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
273     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
274
275     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
276     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
277     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
278     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
279     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
280     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
281     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
282     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
283     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
284     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
285     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
286     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
287     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
288     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
289     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
290     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
291
292     a += r_a;
293     b += r_b;
294     c += r_c;
295     d += r_d;
296
297     COMPARE_M_SIMD (a, d, c, b);
298   }
299 }
300
301 __kernel void m09900_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)
302 {
303 }
304
305 __kernel void m09900_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)
306 {
307 }
308
309 __kernel void m09900_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)
310 {
311   /**
312    * modifier
313    */
314
315   const u32 lid = get_local_id (0);
316
317   /**
318    * base
319    */
320
321   const u32 gid = get_global_id (0);
322
323   if (gid >= gid_max) return;
324
325   u32 pw_buf0[4];
326   u32 pw_buf1[4];
327
328   pw_buf0[0] = pws[gid].i[0];
329   pw_buf0[1] = pws[gid].i[1];
330   pw_buf0[2] = pws[gid].i[2];
331   pw_buf0[3] = pws[gid].i[3];
332   pw_buf1[0] = pws[gid].i[4];
333   pw_buf1[1] = pws[gid].i[5];
334   pw_buf1[2] = pws[gid].i[6];
335   pw_buf1[3] = pws[gid].i[7];
336
337   const u32 pw_l_len = pws[gid].pw_len;
338
339   /**
340    * digest
341    */
342
343   const u32 search[4] =
344   {
345     digests_buf[digests_offset].digest_buf[DGST_R0],
346     digests_buf[digests_offset].digest_buf[DGST_R1],
347     digests_buf[digests_offset].digest_buf[DGST_R2],
348     digests_buf[digests_offset].digest_buf[DGST_R3]
349   };
350
351   /**
352    * loop
353    */
354
355   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
356   {
357     const u32x pw_r_len = pwlenx_create_combt (combs_buf, il_pos);
358
359     const u32x pw_len = pw_l_len + pw_r_len;
360
361     /**
362      * concat password candidate
363      */
364
365     u32x wordl0[4] = { 0 };
366     u32x wordl1[4] = { 0 };
367     u32x wordl2[4] = { 0 };
368     u32x wordl3[4] = { 0 };
369
370     wordl0[0] = pw_buf0[0];
371     wordl0[1] = pw_buf0[1];
372     wordl0[2] = pw_buf0[2];
373     wordl0[3] = pw_buf0[3];
374     wordl1[0] = pw_buf1[0];
375     wordl1[1] = pw_buf1[1];
376     wordl1[2] = pw_buf1[2];
377     wordl1[3] = pw_buf1[3];
378
379     u32x wordr0[4] = { 0 };
380     u32x wordr1[4] = { 0 };
381     u32x wordr2[4] = { 0 };
382     u32x wordr3[4] = { 0 };
383
384     wordr0[0] = ix_create_combt (combs_buf, il_pos, 0);
385     wordr0[1] = ix_create_combt (combs_buf, il_pos, 1);
386     wordr0[2] = ix_create_combt (combs_buf, il_pos, 2);
387     wordr0[3] = ix_create_combt (combs_buf, il_pos, 3);
388     wordr1[0] = ix_create_combt (combs_buf, il_pos, 4);
389     wordr1[1] = ix_create_combt (combs_buf, il_pos, 5);
390     wordr1[2] = ix_create_combt (combs_buf, il_pos, 6);
391     wordr1[3] = ix_create_combt (combs_buf, il_pos, 7);
392
393     if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
394     {
395       switch_buffer_by_offset_le_VV (wordr0, wordr1, wordr2, wordr3, pw_l_len);
396     }
397     else
398     {
399       switch_buffer_by_offset_le_VV (wordl0, wordl1, wordl2, wordl3, pw_r_len);
400     }
401
402     u32x w0[4];
403     u32x w1[4];
404     u32x w2[4];
405     u32x w3[4];
406
407     w0[0] = wordl0[0] | wordr0[0];
408     w0[1] = wordl0[1] | wordr0[1];
409     w0[2] = wordl0[2] | wordr0[2];
410     w0[3] = wordl0[3] | wordr0[3];
411     w1[0] = wordl1[0] | wordr1[0];
412     w1[1] = wordl1[1] | wordr1[1];
413     w1[2] = wordl1[2] | wordr1[2];
414     w1[3] = wordl1[3] | wordr1[3];
415     w2[0] = wordl2[0] | wordr2[0];
416     w2[1] = wordl2[1] | wordr2[1];
417     w2[2] = wordl2[2] | wordr2[2];
418     w2[3] = wordl2[3] | wordr2[3];
419     w3[0] = wordl3[0] | wordr3[0];
420     w3[1] = wordl3[1] | wordr3[1];
421     w3[2] = wordl3[2] | wordr3[2];
422     w3[3] = wordl3[3] | wordr3[3];
423
424     /**
425      * md5
426      */
427
428     u32x a = MD5M_A;
429     u32x b = MD5M_B;
430     u32x c = MD5M_C;
431     u32x d = MD5M_D;
432
433     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
434     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
435     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
436     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
437     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
438     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
439     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
440     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
441     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
442     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
443     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
444     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
445     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
446     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
447     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
448     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
449
450     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
451     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
452     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
453     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
454     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
455     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
456     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
457     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
458     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
459     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
460     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
461     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
462     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
463     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
464     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
465     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
466
467     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
468     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
469     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
470     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
471     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
472     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
473     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
474     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
475     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
476     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
477     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
478     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
479     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
480     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
481     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
482     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
483
484     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
485     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
486     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
487     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
488     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
489     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
490     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
491     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
492     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
493     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
494     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
495     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
496     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
497     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
498     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
499     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
500
501     a += MD5M_A;
502     b += MD5M_B;
503     c += MD5M_C;
504     d += MD5M_D;
505
506     u32x r_a = a;
507     u32x r_b = b;
508     u32x r_c = c;
509     u32x r_d = d;
510
511     w0[0] = 0;
512     w0[1] = 0;
513     w0[2] = 0;
514     w0[3] = 0;
515     w1[0] = 0;
516     w1[1] = 0;
517     w1[2] = 0;
518     w1[3] = 0;
519     w2[0] = 0;
520     w2[1] = 0x80;
521     w2[2] = 0;
522     w2[3] = 0;
523     w3[0] = 0;
524     w3[1] = 0;
525     w3[2] = 100 * 8;
526     w3[3] = 0;
527
528     MD5_STEP (MD5_Fo, a, b, c, d, w0[0], MD5C00, MD5S00);
529     MD5_STEP (MD5_Fo, d, a, b, c, w0[1], MD5C01, MD5S01);
530     MD5_STEP (MD5_Fo, c, d, a, b, w0[2], MD5C02, MD5S02);
531     MD5_STEP (MD5_Fo, b, c, d, a, w0[3], MD5C03, MD5S03);
532     MD5_STEP (MD5_Fo, a, b, c, d, w1[0], MD5C04, MD5S00);
533     MD5_STEP (MD5_Fo, d, a, b, c, w1[1], MD5C05, MD5S01);
534     MD5_STEP (MD5_Fo, c, d, a, b, w1[2], MD5C06, MD5S02);
535     MD5_STEP (MD5_Fo, b, c, d, a, w1[3], MD5C07, MD5S03);
536     MD5_STEP (MD5_Fo, a, b, c, d, w2[0], MD5C08, MD5S00);
537     MD5_STEP (MD5_Fo, d, a, b, c, w2[1], MD5C09, MD5S01);
538     MD5_STEP (MD5_Fo, c, d, a, b, w2[2], MD5C0a, MD5S02);
539     MD5_STEP (MD5_Fo, b, c, d, a, w2[3], MD5C0b, MD5S03);
540     MD5_STEP (MD5_Fo, a, b, c, d, w3[0], MD5C0c, MD5S00);
541     MD5_STEP (MD5_Fo, d, a, b, c, w3[1], MD5C0d, MD5S01);
542     MD5_STEP (MD5_Fo, c, d, a, b, w3[2], MD5C0e, MD5S02);
543     MD5_STEP (MD5_Fo, b, c, d, a, w3[3], MD5C0f, MD5S03);
544
545     MD5_STEP (MD5_Go, a, b, c, d, w0[1], MD5C10, MD5S10);
546     MD5_STEP (MD5_Go, d, a, b, c, w1[2], MD5C11, MD5S11);
547     MD5_STEP (MD5_Go, c, d, a, b, w2[3], MD5C12, MD5S12);
548     MD5_STEP (MD5_Go, b, c, d, a, w0[0], MD5C13, MD5S13);
549     MD5_STEP (MD5_Go, a, b, c, d, w1[1], MD5C14, MD5S10);
550     MD5_STEP (MD5_Go, d, a, b, c, w2[2], MD5C15, MD5S11);
551     MD5_STEP (MD5_Go, c, d, a, b, w3[3], MD5C16, MD5S12);
552     MD5_STEP (MD5_Go, b, c, d, a, w1[0], MD5C17, MD5S13);
553     MD5_STEP (MD5_Go, a, b, c, d, w2[1], MD5C18, MD5S10);
554     MD5_STEP (MD5_Go, d, a, b, c, w3[2], MD5C19, MD5S11);
555     MD5_STEP (MD5_Go, c, d, a, b, w0[3], MD5C1a, MD5S12);
556     MD5_STEP (MD5_Go, b, c, d, a, w2[0], MD5C1b, MD5S13);
557     MD5_STEP (MD5_Go, a, b, c, d, w3[1], MD5C1c, MD5S10);
558     MD5_STEP (MD5_Go, d, a, b, c, w0[2], MD5C1d, MD5S11);
559     MD5_STEP (MD5_Go, c, d, a, b, w1[3], MD5C1e, MD5S12);
560     MD5_STEP (MD5_Go, b, c, d, a, w3[0], MD5C1f, MD5S13);
561
562     MD5_STEP (MD5_H , a, b, c, d, w1[1], MD5C20, MD5S20);
563     MD5_STEP (MD5_H , d, a, b, c, w2[0], MD5C21, MD5S21);
564     MD5_STEP (MD5_H , c, d, a, b, w2[3], MD5C22, MD5S22);
565     MD5_STEP (MD5_H , b, c, d, a, w3[2], MD5C23, MD5S23);
566     MD5_STEP (MD5_H , a, b, c, d, w0[1], MD5C24, MD5S20);
567     MD5_STEP (MD5_H , d, a, b, c, w1[0], MD5C25, MD5S21);
568     MD5_STEP (MD5_H , c, d, a, b, w1[3], MD5C26, MD5S22);
569     MD5_STEP (MD5_H , b, c, d, a, w2[2], MD5C27, MD5S23);
570     MD5_STEP (MD5_H , a, b, c, d, w3[1], MD5C28, MD5S20);
571     MD5_STEP (MD5_H , d, a, b, c, w0[0], MD5C29, MD5S21);
572     MD5_STEP (MD5_H , c, d, a, b, w0[3], MD5C2a, MD5S22);
573     MD5_STEP (MD5_H , b, c, d, a, w1[2], MD5C2b, MD5S23);
574     MD5_STEP (MD5_H , a, b, c, d, w2[1], MD5C2c, MD5S20);
575     MD5_STEP (MD5_H , d, a, b, c, w3[0], MD5C2d, MD5S21);
576     MD5_STEP (MD5_H , c, d, a, b, w3[3], MD5C2e, MD5S22);
577     MD5_STEP (MD5_H , b, c, d, a, w0[2], MD5C2f, MD5S23);
578
579     MD5_STEP (MD5_I , a, b, c, d, w0[0], MD5C30, MD5S30);
580     MD5_STEP (MD5_I , d, a, b, c, w1[3], MD5C31, MD5S31);
581     MD5_STEP (MD5_I , c, d, a, b, w3[2], MD5C32, MD5S32);
582     MD5_STEP (MD5_I , b, c, d, a, w1[1], MD5C33, MD5S33);
583     MD5_STEP (MD5_I , a, b, c, d, w3[0], MD5C34, MD5S30);
584     MD5_STEP (MD5_I , d, a, b, c, w0[3], MD5C35, MD5S31);
585     MD5_STEP (MD5_I , c, d, a, b, w2[2], MD5C36, MD5S32);
586     MD5_STEP (MD5_I , b, c, d, a, w0[1], MD5C37, MD5S33);
587     MD5_STEP (MD5_I , a, b, c, d, w2[0], MD5C38, MD5S30);
588     MD5_STEP (MD5_I , d, a, b, c, w3[3], MD5C39, MD5S31);
589     MD5_STEP (MD5_I , c, d, a, b, w1[2], MD5C3a, MD5S32);
590     MD5_STEP (MD5_I , b, c, d, a, w3[1], MD5C3b, MD5S33);
591     MD5_STEP (MD5_I , a, b, c, d, w1[0], MD5C3c, MD5S30);
592
593     if (MATCHES_NONE_VS ((a + r_a), search[0])) continue;
594
595     MD5_STEP (MD5_I , d, a, b, c, w2[3], MD5C3d, MD5S31);
596     MD5_STEP (MD5_I , c, d, a, b, w0[2], MD5C3e, MD5S32);
597     MD5_STEP (MD5_I , b, c, d, a, w2[1], MD5C3f, MD5S33);
598
599     a += r_a;
600     b += r_b;
601     c += r_c;
602     d += r_d;
603
604     COMPARE_S_SIMD (a, d, c, b);
605   }
606 }
607
608 __kernel void m09900_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)
609 {
610 }
611
612 __kernel void m09900_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)
613 {
614 }