2dfcafb1bb66e783a404804a23db92dc111106a2
[hashcat.git] / OpenCL / m00000_a3_m.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 #define MD5_STEP_REV(f,a,b,c,d,x,t,s)   \
18 {                                       \
19   a -= b;                               \
20   a  = rotr32_S (a, s);                 \
21   a -= f (b, c, d);                     \
22   a -= x;                               \
23   a -= t;                               \
24 }
25
26 #define MD5_STEP_REV1(f,a,b,c,d,x,t,s)  \
27 {                                       \
28   a -= b;                               \
29   a  = rotr32_S (a, s);                 \
30   a -= x;                               \
31   a -= t;                               \
32 }
33
34 void m00000m (u32 w[16], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
35 {
36   /**
37    * modifier
38    */
39
40   const u32 gid = get_global_id (0);
41   const u32 lid = get_local_id (0);
42
43   /**
44    * base
45    */
46
47   const u32 F_w0c00 =    0  + MD5C00;
48   const u32 F_w1c01 = w[ 1] + MD5C01;
49   const u32 F_w2c02 = w[ 2] + MD5C02;
50   const u32 F_w3c03 = w[ 3] + MD5C03;
51   const u32 F_w4c04 = w[ 4] + MD5C04;
52   const u32 F_w5c05 = w[ 5] + MD5C05;
53   const u32 F_w6c06 = w[ 6] + MD5C06;
54   const u32 F_w7c07 = w[ 7] + MD5C07;
55   const u32 F_w8c08 = w[ 8] + MD5C08;
56   const u32 F_w9c09 = w[ 9] + MD5C09;
57   const u32 F_wac0a = w[10] + MD5C0a;
58   const u32 F_wbc0b = w[11] + MD5C0b;
59   const u32 F_wcc0c = w[12] + MD5C0c;
60   const u32 F_wdc0d = w[13] + MD5C0d;
61   const u32 F_wec0e = w[14] + MD5C0e;
62   const u32 F_wfc0f = w[15] + MD5C0f;
63
64   const u32 G_w1c10 = w[ 1] + MD5C10;
65   const u32 G_w6c11 = w[ 6] + MD5C11;
66   const u32 G_wbc12 = w[11] + MD5C12;
67   const u32 G_w0c13 =    0  + MD5C13;
68   const u32 G_w5c14 = w[ 5] + MD5C14;
69   const u32 G_wac15 = w[10] + MD5C15;
70   const u32 G_wfc16 = w[15] + MD5C16;
71   const u32 G_w4c17 = w[ 4] + MD5C17;
72   const u32 G_w9c18 = w[ 9] + MD5C18;
73   const u32 G_wec19 = w[14] + MD5C19;
74   const u32 G_w3c1a = w[ 3] + MD5C1a;
75   const u32 G_w8c1b = w[ 8] + MD5C1b;
76   const u32 G_wdc1c = w[13] + MD5C1c;
77   const u32 G_w2c1d = w[ 2] + MD5C1d;
78   const u32 G_w7c1e = w[ 7] + MD5C1e;
79   const u32 G_wcc1f = w[12] + MD5C1f;
80
81   const u32 H_w5c20 = w[ 5] + MD5C20;
82   const u32 H_w8c21 = w[ 8] + MD5C21;
83   const u32 H_wbc22 = w[11] + MD5C22;
84   const u32 H_wec23 = w[14] + MD5C23;
85   const u32 H_w1c24 = w[ 1] + MD5C24;
86   const u32 H_w4c25 = w[ 4] + MD5C25;
87   const u32 H_w7c26 = w[ 7] + MD5C26;
88   const u32 H_wac27 = w[10] + MD5C27;
89   const u32 H_wdc28 = w[13] + MD5C28;
90   const u32 H_w0c29 =    0  + MD5C29;
91   const u32 H_w3c2a = w[ 3] + MD5C2a;
92   const u32 H_w6c2b = w[ 6] + MD5C2b;
93   const u32 H_w9c2c = w[ 9] + MD5C2c;
94   const u32 H_wcc2d = w[12] + MD5C2d;
95   const u32 H_wfc2e = w[15] + MD5C2e;
96   const u32 H_w2c2f = w[ 2] + MD5C2f;
97
98   const u32 I_w0c30 =    0  + MD5C30;
99   const u32 I_w7c31 = w[ 7] + MD5C31;
100   const u32 I_wec32 = w[14] + MD5C32;
101   const u32 I_w5c33 = w[ 5] + MD5C33;
102   const u32 I_wcc34 = w[12] + MD5C34;
103   const u32 I_w3c35 = w[ 3] + MD5C35;
104   const u32 I_wac36 = w[10] + MD5C36;
105   const u32 I_w1c37 = w[ 1] + MD5C37;
106   const u32 I_w8c38 = w[ 8] + MD5C38;
107   const u32 I_wfc39 = w[15] + MD5C39;
108   const u32 I_w6c3a = w[ 6] + MD5C3a;
109   const u32 I_wdc3b = w[13] + MD5C3b;
110   const u32 I_w4c3c = w[ 4] + MD5C3c;
111   const u32 I_wbc3d = w[11] + MD5C3d;
112   const u32 I_w2c3e = w[ 2] + MD5C3e;
113   const u32 I_w9c3f = w[ 9] + MD5C3f;
114
115   /**
116    * loop
117    */
118
119   u32 w0l = w[0];
120
121   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
122   {
123     const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
124
125     const u32x w0 = w0l | w0r;
126
127     u32x a = MD5M_A;
128     u32x b = MD5M_B;
129     u32x c = MD5M_C;
130     u32x d = MD5M_D;
131
132     MD5_STEP (MD5_Fo, a, b, c, d, w0, F_w0c00, MD5S00);
133     MD5_STEP0(MD5_Fo, d, a, b, c,     F_w1c01, MD5S01);
134     MD5_STEP0(MD5_Fo, c, d, a, b,     F_w2c02, MD5S02);
135     MD5_STEP0(MD5_Fo, b, c, d, a,     F_w3c03, MD5S03);
136     MD5_STEP0(MD5_Fo, a, b, c, d,     F_w4c04, MD5S00);
137     MD5_STEP0(MD5_Fo, d, a, b, c,     F_w5c05, MD5S01);
138     MD5_STEP0(MD5_Fo, c, d, a, b,     F_w6c06, MD5S02);
139     MD5_STEP0(MD5_Fo, b, c, d, a,     F_w7c07, MD5S03);
140     MD5_STEP0(MD5_Fo, a, b, c, d,     F_w8c08, MD5S00);
141     MD5_STEP0(MD5_Fo, d, a, b, c,     F_w9c09, MD5S01);
142     MD5_STEP0(MD5_Fo, c, d, a, b,     F_wac0a, MD5S02);
143     MD5_STEP0(MD5_Fo, b, c, d, a,     F_wbc0b, MD5S03);
144     MD5_STEP0(MD5_Fo, a, b, c, d,     F_wcc0c, MD5S00);
145     MD5_STEP0(MD5_Fo, d, a, b, c,     F_wdc0d, MD5S01);
146     MD5_STEP0(MD5_Fo, c, d, a, b,     F_wec0e, MD5S02);
147     MD5_STEP0(MD5_Fo, b, c, d, a,     F_wfc0f, MD5S03);
148
149     MD5_STEP0(MD5_Go, a, b, c, d,     G_w1c10, MD5S10);
150     MD5_STEP0(MD5_Go, d, a, b, c,     G_w6c11, MD5S11);
151     MD5_STEP0(MD5_Go, c, d, a, b,     G_wbc12, MD5S12);
152     MD5_STEP (MD5_Go, b, c, d, a, w0, G_w0c13, MD5S13);
153     MD5_STEP0(MD5_Go, a, b, c, d,     G_w5c14, MD5S10);
154     MD5_STEP0(MD5_Go, d, a, b, c,     G_wac15, MD5S11);
155     MD5_STEP0(MD5_Go, c, d, a, b,     G_wfc16, MD5S12);
156     MD5_STEP0(MD5_Go, b, c, d, a,     G_w4c17, MD5S13);
157     MD5_STEP0(MD5_Go, a, b, c, d,     G_w9c18, MD5S10);
158     MD5_STEP0(MD5_Go, d, a, b, c,     G_wec19, MD5S11);
159     MD5_STEP0(MD5_Go, c, d, a, b,     G_w3c1a, MD5S12);
160     MD5_STEP0(MD5_Go, b, c, d, a,     G_w8c1b, MD5S13);
161     MD5_STEP0(MD5_Go, a, b, c, d,     G_wdc1c, MD5S10);
162     MD5_STEP0(MD5_Go, d, a, b, c,     G_w2c1d, MD5S11);
163     MD5_STEP0(MD5_Go, c, d, a, b,     G_w7c1e, MD5S12);
164     MD5_STEP0(MD5_Go, b, c, d, a,     G_wcc1f, MD5S13);
165
166     MD5_STEP0(MD5_H , a, b, c, d,     H_w5c20, MD5S20);
167     MD5_STEP0(MD5_H , d, a, b, c,     H_w8c21, MD5S21);
168     MD5_STEP0(MD5_H , c, d, a, b,     H_wbc22, MD5S22);
169     MD5_STEP0(MD5_H , b, c, d, a,     H_wec23, MD5S23);
170     MD5_STEP0(MD5_H , a, b, c, d,     H_w1c24, MD5S20);
171     MD5_STEP0(MD5_H , d, a, b, c,     H_w4c25, MD5S21);
172     MD5_STEP0(MD5_H , c, d, a, b,     H_w7c26, MD5S22);
173     MD5_STEP0(MD5_H , b, c, d, a,     H_wac27, MD5S23);
174     MD5_STEP0(MD5_H , a, b, c, d,     H_wdc28, MD5S20);
175     MD5_STEP (MD5_H , d, a, b, c, w0, H_w0c29, MD5S21);
176     MD5_STEP0(MD5_H , c, d, a, b,     H_w3c2a, MD5S22);
177     MD5_STEP0(MD5_H , b, c, d, a,     H_w6c2b, MD5S23);
178     MD5_STEP0(MD5_H , a, b, c, d,     H_w9c2c, MD5S20);
179     MD5_STEP0(MD5_H , d, a, b, c,     H_wcc2d, MD5S21);
180     MD5_STEP0(MD5_H , c, d, a, b,     H_wfc2e, MD5S22);
181     MD5_STEP0(MD5_H , b, c, d, a,     H_w2c2f, MD5S23);
182
183     MD5_STEP (MD5_I , a, b, c, d, w0, I_w0c30, MD5S30);
184     MD5_STEP0(MD5_I , d, a, b, c,     I_w7c31, MD5S31);
185     MD5_STEP0(MD5_I , c, d, a, b,     I_wec32, MD5S32);
186     MD5_STEP0(MD5_I , b, c, d, a,     I_w5c33, MD5S33);
187     MD5_STEP0(MD5_I , a, b, c, d,     I_wcc34, MD5S30);
188     MD5_STEP0(MD5_I , d, a, b, c,     I_w3c35, MD5S31);
189     MD5_STEP0(MD5_I , c, d, a, b,     I_wac36, MD5S32);
190     MD5_STEP0(MD5_I , b, c, d, a,     I_w1c37, MD5S33);
191     MD5_STEP0(MD5_I , a, b, c, d,     I_w8c38, MD5S30);
192     MD5_STEP0(MD5_I , d, a, b, c,     I_wfc39, MD5S31);
193     MD5_STEP0(MD5_I , c, d, a, b,     I_w6c3a, MD5S32);
194     MD5_STEP0(MD5_I , b, c, d, a,     I_wdc3b, MD5S33);
195     MD5_STEP0(MD5_I , a, b, c, d,     I_w4c3c, MD5S30);
196     MD5_STEP0(MD5_I , d, a, b, c,     I_wbc3d, MD5S31);
197     MD5_STEP0(MD5_I , c, d, a, b,     I_w2c3e, MD5S32);
198     MD5_STEP0(MD5_I , b, c, d, a,     I_w9c3f, MD5S33);
199
200     COMPARE_M_SIMD (a, d, c, b);
201   }
202 }
203
204 void m00000s (u32 w[16], const u32 pw_len, __global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
205 {
206   /**
207    * modifier
208    */
209
210   const u32 gid = get_global_id (0);
211   const u32 lid = get_local_id (0);
212
213   /**
214    * base
215    */
216
217   const u32 F_w0c00 =    0  + MD5C00;
218   const u32 F_w1c01 = w[ 1] + MD5C01;
219   const u32 F_w2c02 = w[ 2] + MD5C02;
220   const u32 F_w3c03 = w[ 3] + MD5C03;
221   const u32 F_w4c04 = w[ 4] + MD5C04;
222   const u32 F_w5c05 = w[ 5] + MD5C05;
223   const u32 F_w6c06 = w[ 6] + MD5C06;
224   const u32 F_w7c07 = w[ 7] + MD5C07;
225   const u32 F_w8c08 = w[ 8] + MD5C08;
226   const u32 F_w9c09 = w[ 9] + MD5C09;
227   const u32 F_wac0a = w[10] + MD5C0a;
228   const u32 F_wbc0b = w[11] + MD5C0b;
229   const u32 F_wcc0c = w[12] + MD5C0c;
230   const u32 F_wdc0d = w[13] + MD5C0d;
231   const u32 F_wec0e = w[14] + MD5C0e;
232   const u32 F_wfc0f = w[15] + MD5C0f;
233
234   const u32 G_w1c10 = w[ 1] + MD5C10;
235   const u32 G_w6c11 = w[ 6] + MD5C11;
236   const u32 G_wbc12 = w[11] + MD5C12;
237   const u32 G_w0c13 =    0  + MD5C13;
238   const u32 G_w5c14 = w[ 5] + MD5C14;
239   const u32 G_wac15 = w[10] + MD5C15;
240   const u32 G_wfc16 = w[15] + MD5C16;
241   const u32 G_w4c17 = w[ 4] + MD5C17;
242   const u32 G_w9c18 = w[ 9] + MD5C18;
243   const u32 G_wec19 = w[14] + MD5C19;
244   const u32 G_w3c1a = w[ 3] + MD5C1a;
245   const u32 G_w8c1b = w[ 8] + MD5C1b;
246   const u32 G_wdc1c = w[13] + MD5C1c;
247   const u32 G_w2c1d = w[ 2] + MD5C1d;
248   const u32 G_w7c1e = w[ 7] + MD5C1e;
249   const u32 G_wcc1f = w[12] + MD5C1f;
250
251   const u32 H_w5c20 = w[ 5] + MD5C20;
252   const u32 H_w8c21 = w[ 8] + MD5C21;
253   const u32 H_wbc22 = w[11] + MD5C22;
254   const u32 H_wec23 = w[14] + MD5C23;
255   const u32 H_w1c24 = w[ 1] + MD5C24;
256   const u32 H_w4c25 = w[ 4] + MD5C25;
257   const u32 H_w7c26 = w[ 7] + MD5C26;
258   const u32 H_wac27 = w[10] + MD5C27;
259   const u32 H_wdc28 = w[13] + MD5C28;
260   const u32 H_w0c29 =    0  + MD5C29;
261   const u32 H_w3c2a = w[ 3] + MD5C2a;
262   const u32 H_w6c2b = w[ 6] + MD5C2b;
263   const u32 H_w9c2c = w[ 9] + MD5C2c;
264   const u32 H_wcc2d = w[12] + MD5C2d;
265   const u32 H_wfc2e = w[15] + MD5C2e;
266   const u32 H_w2c2f = w[ 2] + MD5C2f;
267
268   const u32 I_w0c30 =    0  + MD5C30;
269   const u32 I_w7c31 = w[ 7] + MD5C31;
270   const u32 I_wec32 = w[14] + MD5C32;
271   const u32 I_w5c33 = w[ 5] + MD5C33;
272   const u32 I_wcc34 = w[12] + MD5C34;
273   const u32 I_w3c35 = w[ 3] + MD5C35;
274   const u32 I_wac36 = w[10] + MD5C36;
275   const u32 I_w1c37 = w[ 1] + MD5C37;
276   const u32 I_w8c38 = w[ 8] + MD5C38;
277   const u32 I_wfc39 = w[15] + MD5C39;
278   const u32 I_w6c3a = w[ 6] + MD5C3a;
279   const u32 I_wdc3b = w[13] + MD5C3b;
280   const u32 I_w4c3c = w[ 4] + MD5C3c;
281   const u32 I_wbc3d = w[11] + MD5C3d;
282   const u32 I_w2c3e = w[ 2] + MD5C3e;
283   const u32 I_w9c3f = w[ 9] + MD5C3f;
284
285   /**
286    * digest
287    */
288
289   const u32 search[4] =
290   {
291     digests_buf[digests_offset].digest_buf[DGST_R0],
292     digests_buf[digests_offset].digest_buf[DGST_R1],
293     digests_buf[digests_offset].digest_buf[DGST_R2],
294     digests_buf[digests_offset].digest_buf[DGST_R3]
295   };
296
297   /**
298    * reverse
299    */
300
301   u32 a_rev = digests_buf[digests_offset].digest_buf[0];
302   u32 b_rev = digests_buf[digests_offset].digest_buf[1];
303   u32 c_rev = digests_buf[digests_offset].digest_buf[2];
304   u32 d_rev = digests_buf[digests_offset].digest_buf[3];
305
306   MD5_STEP_REV (MD5_I_S, b_rev, c_rev, d_rev, a_rev, w[ 9], MD5C3f, MD5S33);
307   MD5_STEP_REV (MD5_I_S, c_rev, d_rev, a_rev, b_rev, w[ 2], MD5C3e, MD5S32);
308   MD5_STEP_REV (MD5_I_S, d_rev, a_rev, b_rev, c_rev, w[11], MD5C3d, MD5S31);
309   MD5_STEP_REV (MD5_I_S, a_rev, b_rev, c_rev, d_rev, w[ 4], MD5C3c, MD5S30);
310   MD5_STEP_REV (MD5_I_S, b_rev, c_rev, d_rev, a_rev, w[13], MD5C3b, MD5S33);
311   MD5_STEP_REV (MD5_I_S, c_rev, d_rev, a_rev, b_rev, w[ 6], MD5C3a, MD5S32);
312   MD5_STEP_REV (MD5_I_S, d_rev, a_rev, b_rev, c_rev, w[15], MD5C39, MD5S31);
313   MD5_STEP_REV (MD5_I_S, a_rev, b_rev, c_rev, d_rev, w[ 8], MD5C38, MD5S30);
314   MD5_STEP_REV (MD5_I_S, b_rev, c_rev, d_rev, a_rev, w[ 1], MD5C37, MD5S33);
315   MD5_STEP_REV (MD5_I_S, c_rev, d_rev, a_rev, b_rev, w[10], MD5C36, MD5S32);
316   MD5_STEP_REV (MD5_I_S, d_rev, a_rev, b_rev, c_rev, w[ 3], MD5C35, MD5S31);
317   MD5_STEP_REV (MD5_I_S, a_rev, b_rev, c_rev, d_rev, w[12], MD5C34, MD5S30);
318   MD5_STEP_REV (MD5_I_S, b_rev, c_rev, d_rev, a_rev, w[ 5], MD5C33, MD5S33);
319   MD5_STEP_REV (MD5_I_S, c_rev, d_rev, a_rev, b_rev, w[14], MD5C32, MD5S32);
320   MD5_STEP_REV (MD5_I_S, d_rev, a_rev, b_rev, c_rev, w[ 7], MD5C31, MD5S31);
321   MD5_STEP_REV (MD5_I_S, a_rev, b_rev, c_rev, d_rev,     0, MD5C30, MD5S30);
322
323   const u32 pre_cd = c_rev ^ d_rev;
324
325   MD5_STEP_REV1(MD5_H_S, b_rev, c_rev, d_rev, a_rev, w[ 2], MD5C2f, MD5S23);
326   MD5_STEP_REV1(MD5_H_S, c_rev, d_rev, a_rev, b_rev, w[15], MD5C2e, MD5S22);
327
328   /**
329    * loop
330    */
331
332   u32 w0l = w[0];
333
334   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
335   {
336     const u32x w0r = words_buf_r[il_pos / VECT_SIZE];
337
338     const u32x w0 = w0l | w0r;
339
340     const u32x pre_d = d_rev;
341     const u32x pre_a = a_rev - w0;
342     const u32x pre_b = b_rev - (pre_a ^ pre_cd);
343     const u32x pre_c = c_rev - (pre_a ^ pre_b ^ pre_d);
344
345     u32x a = MD5M_A;
346     u32x b = MD5M_B;
347     u32x c = MD5M_C;
348     u32x d = MD5M_D;
349
350     MD5_STEP (MD5_Fo, a, b, c, d, w0, F_w0c00, MD5S00);
351     MD5_STEP0(MD5_Fo, d, a, b, c,     F_w1c01, MD5S01);
352     MD5_STEP0(MD5_Fo, c, d, a, b,     F_w2c02, MD5S02);
353     MD5_STEP0(MD5_Fo, b, c, d, a,     F_w3c03, MD5S03);
354     MD5_STEP0(MD5_Fo, a, b, c, d,     F_w4c04, MD5S00);
355     MD5_STEP0(MD5_Fo, d, a, b, c,     F_w5c05, MD5S01);
356     MD5_STEP0(MD5_Fo, c, d, a, b,     F_w6c06, MD5S02);
357     MD5_STEP0(MD5_Fo, b, c, d, a,     F_w7c07, MD5S03);
358     MD5_STEP0(MD5_Fo, a, b, c, d,     F_w8c08, MD5S00);
359     MD5_STEP0(MD5_Fo, d, a, b, c,     F_w9c09, MD5S01);
360     MD5_STEP0(MD5_Fo, c, d, a, b,     F_wac0a, MD5S02);
361     MD5_STEP0(MD5_Fo, b, c, d, a,     F_wbc0b, MD5S03);
362     MD5_STEP0(MD5_Fo, a, b, c, d,     F_wcc0c, MD5S00);
363     MD5_STEP0(MD5_Fo, d, a, b, c,     F_wdc0d, MD5S01);
364     MD5_STEP0(MD5_Fo, c, d, a, b,     F_wec0e, MD5S02);
365     MD5_STEP0(MD5_Fo, b, c, d, a,     F_wfc0f, MD5S03);
366
367     MD5_STEP0(MD5_Go, a, b, c, d,     G_w1c10, MD5S10);
368     MD5_STEP0(MD5_Go, d, a, b, c,     G_w6c11, MD5S11);
369     MD5_STEP0(MD5_Go, c, d, a, b,     G_wbc12, MD5S12);
370     MD5_STEP (MD5_Go, b, c, d, a, w0, G_w0c13, MD5S13);
371     MD5_STEP0(MD5_Go, a, b, c, d,     G_w5c14, MD5S10);
372     MD5_STEP0(MD5_Go, d, a, b, c,     G_wac15, MD5S11);
373     MD5_STEP0(MD5_Go, c, d, a, b,     G_wfc16, MD5S12);
374     MD5_STEP0(MD5_Go, b, c, d, a,     G_w4c17, MD5S13);
375     MD5_STEP0(MD5_Go, a, b, c, d,     G_w9c18, MD5S10);
376     MD5_STEP0(MD5_Go, d, a, b, c,     G_wec19, MD5S11);
377     MD5_STEP0(MD5_Go, c, d, a, b,     G_w3c1a, MD5S12);
378     MD5_STEP0(MD5_Go, b, c, d, a,     G_w8c1b, MD5S13);
379     MD5_STEP0(MD5_Go, a, b, c, d,     G_wdc1c, MD5S10);
380     MD5_STEP0(MD5_Go, d, a, b, c,     G_w2c1d, MD5S11);
381     MD5_STEP0(MD5_Go, c, d, a, b,     G_w7c1e, MD5S12);
382     MD5_STEP0(MD5_Go, b, c, d, a,     G_wcc1f, MD5S13);
383
384     MD5_STEP0(MD5_H , a, b, c, d,     H_w5c20, MD5S20);
385     MD5_STEP0(MD5_H , d, a, b, c,     H_w8c21, MD5S21);
386     MD5_STEP0(MD5_H , c, d, a, b,     H_wbc22, MD5S22);
387     MD5_STEP0(MD5_H , b, c, d, a,     H_wec23, MD5S23);
388     MD5_STEP0(MD5_H , a, b, c, d,     H_w1c24, MD5S20);
389     MD5_STEP0(MD5_H , d, a, b, c,     H_w4c25, MD5S21);
390     MD5_STEP0(MD5_H , c, d, a, b,     H_w7c26, MD5S22);
391     MD5_STEP0(MD5_H , b, c, d, a,     H_wac27, MD5S23);
392     MD5_STEP0(MD5_H , a, b, c, d,     H_wdc28, MD5S20);
393     MD5_STEP (MD5_H , d, a, b, c, w0, H_w0c29, MD5S21);
394     MD5_STEP0(MD5_H , c, d, a, b,     H_w3c2a, MD5S22);
395
396     if (MATCHES_NONE_VV (pre_c, c)) continue;
397
398     MD5_STEP0(MD5_H , b, c, d, a,     H_w6c2b, MD5S23);
399     MD5_STEP0(MD5_H , a, b, c, d,     H_w9c2c, MD5S20);
400     MD5_STEP0(MD5_H , d, a, b, c,     H_wcc2d, MD5S21);
401
402     if (MATCHES_NONE_VV (pre_d, d)) continue;
403
404     MD5_STEP0(MD5_H , c, d, a, b,     H_wfc2e, MD5S22);
405     MD5_STEP0(MD5_H , b, c, d, a,     H_w2c2f, MD5S23);
406
407     MD5_STEP (MD5_I , a, b, c, d, w0, I_w0c30, MD5S30);
408     MD5_STEP0(MD5_I , d, a, b, c,     I_w7c31, MD5S31);
409     MD5_STEP0(MD5_I , c, d, a, b,     I_wec32, MD5S32);
410     MD5_STEP0(MD5_I , b, c, d, a,     I_w5c33, MD5S33);
411     MD5_STEP0(MD5_I , a, b, c, d,     I_wcc34, MD5S30);
412     MD5_STEP0(MD5_I , d, a, b, c,     I_w3c35, MD5S31);
413     MD5_STEP0(MD5_I , c, d, a, b,     I_wac36, MD5S32);
414     MD5_STEP0(MD5_I , b, c, d, a,     I_w1c37, MD5S33);
415     MD5_STEP0(MD5_I , a, b, c, d,     I_w8c38, MD5S30);
416     MD5_STEP0(MD5_I , d, a, b, c,     I_wfc39, MD5S31);
417     MD5_STEP0(MD5_I , c, d, a, b,     I_w6c3a, MD5S32);
418     MD5_STEP0(MD5_I , b, c, d, a,     I_wdc3b, MD5S33);
419     MD5_STEP0(MD5_I , a, b, c, d,     I_w4c3c, MD5S30);
420     MD5_STEP0(MD5_I , d, a, b, c,     I_wbc3d, MD5S31);
421     MD5_STEP0(MD5_I , c, d, a, b,     I_w2c3e, MD5S32);
422     MD5_STEP0(MD5_I , b, c, d, a,     I_w9c3f, MD5S33);
423
424     COMPARE_S_SIMD (a, d, c, b);
425   }
426 }
427
428 __kernel void m00000_m04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
429 {
430   /**
431    * base
432    */
433
434   const u32 gid = get_global_id (0);
435
436   if (gid >= gid_max) return;
437
438   u32 w[16];
439
440   w[ 0] = pws[gid].i[ 0];
441   w[ 1] = pws[gid].i[ 1];
442   w[ 2] = pws[gid].i[ 2];
443   w[ 3] = pws[gid].i[ 3];
444   w[ 4] = 0;
445   w[ 5] = 0;
446   w[ 6] = 0;
447   w[ 7] = 0;
448   w[ 8] = 0;
449   w[ 9] = 0;
450   w[10] = 0;
451   w[11] = 0;
452   w[12] = 0;
453   w[13] = 0;
454   w[14] = pws[gid].i[14];
455   w[15] = 0;
456
457   const u32 pw_len = pws[gid].pw_len;
458
459   /**
460    * main
461    */
462
463   m00000m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
464 }
465
466 __kernel void m00000_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
467 {
468   /**
469    * base
470    */
471
472   const u32 gid = get_global_id (0);
473
474   if (gid >= gid_max) return;
475
476   u32 w[16];
477
478   w[ 0] = pws[gid].i[ 0];
479   w[ 1] = pws[gid].i[ 1];
480   w[ 2] = pws[gid].i[ 2];
481   w[ 3] = pws[gid].i[ 3];
482   w[ 4] = pws[gid].i[ 4];
483   w[ 5] = pws[gid].i[ 5];
484   w[ 6] = pws[gid].i[ 6];
485   w[ 7] = pws[gid].i[ 7];
486   w[ 8] = 0;
487   w[ 9] = 0;
488   w[10] = 0;
489   w[11] = 0;
490   w[12] = 0;
491   w[13] = 0;
492   w[14] = pws[gid].i[14];
493   w[15] = 0;
494
495   const u32 pw_len = pws[gid].pw_len;
496
497   /**
498    * main
499    */
500
501   m00000m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
502 }
503
504 __kernel void m00000_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
505 {
506   /**
507    * base
508    */
509
510   const u32 gid = get_global_id (0);
511
512   if (gid >= gid_max) return;
513
514   u32 w[16];
515
516   w[ 0] = pws[gid].i[ 0];
517   w[ 1] = pws[gid].i[ 1];
518   w[ 2] = pws[gid].i[ 2];
519   w[ 3] = pws[gid].i[ 3];
520   w[ 4] = pws[gid].i[ 4];
521   w[ 5] = pws[gid].i[ 5];
522   w[ 6] = pws[gid].i[ 6];
523   w[ 7] = pws[gid].i[ 7];
524   w[ 8] = pws[gid].i[ 8];
525   w[ 9] = pws[gid].i[ 9];
526   w[10] = pws[gid].i[10];
527   w[11] = pws[gid].i[11];
528   w[12] = pws[gid].i[12];
529   w[13] = pws[gid].i[13];
530   w[14] = pws[gid].i[14];
531   w[15] = pws[gid].i[15];
532
533   const u32 pw_len = pws[gid].pw_len;
534
535   /**
536    * main
537    */
538
539   m00000m (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
540 }
541
542 __kernel void m00000_s04 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
543 {
544   /**
545    * base
546    */
547
548   const u32 gid = get_global_id (0);
549
550   if (gid >= gid_max) return;
551
552   u32 w[16];
553
554   w[ 0] = pws[gid].i[ 0];
555   w[ 1] = pws[gid].i[ 1];
556   w[ 2] = pws[gid].i[ 2];
557   w[ 3] = pws[gid].i[ 3];
558   w[ 4] = 0;
559   w[ 5] = 0;
560   w[ 6] = 0;
561   w[ 7] = 0;
562   w[ 8] = 0;
563   w[ 9] = 0;
564   w[10] = 0;
565   w[11] = 0;
566   w[12] = 0;
567   w[13] = 0;
568   w[14] = pws[gid].i[14];
569   w[15] = 0;
570
571   const u32 pw_len = pws[gid].pw_len;
572
573   /**
574    * main
575    */
576
577   m00000s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
578 }
579
580 __kernel void m00000_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
581 {
582   /**
583    * base
584    */
585
586   const u32 gid = get_global_id (0);
587
588   if (gid >= gid_max) return;
589
590   u32 w[16];
591
592   w[ 0] = pws[gid].i[ 0];
593   w[ 1] = pws[gid].i[ 1];
594   w[ 2] = pws[gid].i[ 2];
595   w[ 3] = pws[gid].i[ 3];
596   w[ 4] = pws[gid].i[ 4];
597   w[ 5] = pws[gid].i[ 5];
598   w[ 6] = pws[gid].i[ 6];
599   w[ 7] = pws[gid].i[ 7];
600   w[ 8] = 0;
601   w[ 9] = 0;
602   w[10] = 0;
603   w[11] = 0;
604   w[12] = 0;
605   w[13] = 0;
606   w[14] = pws[gid].i[14];
607   w[15] = 0;
608
609   const u32 pw_len = pws[gid].pw_len;
610
611   /**
612    * main
613    */
614
615   m00000s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
616 }
617
618 __kernel void m00000_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __constant u32x * words_buf_r, __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)
619 {
620   /**
621    * base
622    */
623
624   const u32 gid = get_global_id (0);
625
626   if (gid >= gid_max) return;
627
628   u32 w[16];
629
630   w[ 0] = pws[gid].i[ 0];
631   w[ 1] = pws[gid].i[ 1];
632   w[ 2] = pws[gid].i[ 2];
633   w[ 3] = pws[gid].i[ 3];
634   w[ 4] = pws[gid].i[ 4];
635   w[ 5] = pws[gid].i[ 5];
636   w[ 6] = pws[gid].i[ 6];
637   w[ 7] = pws[gid].i[ 7];
638   w[ 8] = pws[gid].i[ 8];
639   w[ 9] = pws[gid].i[ 9];
640   w[10] = pws[gid].i[10];
641   w[11] = pws[gid].i[11];
642   w[12] = pws[gid].i[12];
643   w[13] = pws[gid].i[13];
644   w[14] = pws[gid].i[14];
645   w[15] = pws[gid].i[15];
646
647   const u32 pw_len = pws[gid].pw_len;
648
649   /**
650    * main
651    */
652
653   m00000s (w, pw_len, pws, rules_buf, combs_buf, words_buf_r, tmps, hooks, bitmaps_buf_s1_a, bitmaps_buf_s1_b, bitmaps_buf_s1_c, bitmaps_buf_s1_d, bitmaps_buf_s2_a, bitmaps_buf_s2_b, bitmaps_buf_s2_c, bitmaps_buf_s2_d, plains_buf, digests_buf, hashes_shown, salt_bufs, esalt_bufs, d_return_buf, d_scryptV0_buf, d_scryptV1_buf, d_scryptV2_buf, d_scryptV3_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, il_cnt, digests_cnt, digests_offset);
654 }