Merge branch 'GetRidOfCUDA'
[hashcat.git] / OpenCL / m00150_a3.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _SHA1_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #define DGST_R0 3
12 #define DGST_R1 4
13 #define DGST_R2 2
14 #define DGST_R3 1
15
16 #include "include/kernel_functions.c"
17 #include "types_ocl.c"
18 #include "common.c"
19
20 #define COMPARE_S "check_single_comp4.c"
21 #define COMPARE_M "check_multi_comp4.c"
22
23 static void sha1_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[5])
24 {
25   u32 A = digest[0];
26   u32 B = digest[1];
27   u32 C = digest[2];
28   u32 D = digest[3];
29   u32 E = digest[4];
30
31   u32 w0_t = w0[0];
32   u32 w1_t = w0[1];
33   u32 w2_t = w0[2];
34   u32 w3_t = w0[3];
35   u32 w4_t = w1[0];
36   u32 w5_t = w1[1];
37   u32 w6_t = w1[2];
38   u32 w7_t = w1[3];
39   u32 w8_t = w2[0];
40   u32 w9_t = w2[1];
41   u32 wa_t = w2[2];
42   u32 wb_t = w2[3];
43   u32 wc_t = w3[0];
44   u32 wd_t = w3[1];
45   u32 we_t = w3[2];
46   u32 wf_t = w3[3];
47
48   #undef K
49   #define K SHA1C00
50
51   SHA1_STEP (SHA1_F0o, A, B, C, D, E, w0_t);
52   SHA1_STEP (SHA1_F0o, E, A, B, C, D, w1_t);
53   SHA1_STEP (SHA1_F0o, D, E, A, B, C, w2_t);
54   SHA1_STEP (SHA1_F0o, C, D, E, A, B, w3_t);
55   SHA1_STEP (SHA1_F0o, B, C, D, E, A, w4_t);
56   SHA1_STEP (SHA1_F0o, A, B, C, D, E, w5_t);
57   SHA1_STEP (SHA1_F0o, E, A, B, C, D, w6_t);
58   SHA1_STEP (SHA1_F0o, D, E, A, B, C, w7_t);
59   SHA1_STEP (SHA1_F0o, C, D, E, A, B, w8_t);
60   SHA1_STEP (SHA1_F0o, B, C, D, E, A, w9_t);
61   SHA1_STEP (SHA1_F0o, A, B, C, D, E, wa_t);
62   SHA1_STEP (SHA1_F0o, E, A, B, C, D, wb_t);
63   SHA1_STEP (SHA1_F0o, D, E, A, B, C, wc_t);
64   SHA1_STEP (SHA1_F0o, C, D, E, A, B, wd_t);
65   SHA1_STEP (SHA1_F0o, B, C, D, E, A, we_t);
66   SHA1_STEP (SHA1_F0o, A, B, C, D, E, wf_t);
67   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, E, A, B, C, D, w0_t);
68   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, D, E, A, B, C, w1_t);
69   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, C, D, E, A, B, w2_t);
70   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, B, C, D, E, A, w3_t);
71
72   #undef K
73   #define K SHA1C01
74
75   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w4_t);
76   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w5_t);
77   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w6_t);
78   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w7_t);
79   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w8_t);
80   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w9_t);
81   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wa_t);
82   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, wb_t);
83   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, wc_t);
84   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wd_t);
85   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, we_t);
86   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wf_t);
87   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w0_t);
88   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w1_t);
89   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w2_t);
90   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w3_t);
91   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w4_t);
92   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w5_t);
93   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w6_t);
94   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w7_t);
95
96   #undef K
97   #define K SHA1C02
98
99   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w8_t);
100   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w9_t);
101   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, wa_t);
102   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, wb_t);
103   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, wc_t);
104   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, wd_t);
105   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, we_t);
106   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, wf_t);
107   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, w0_t);
108   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, w1_t);
109   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w2_t);
110   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w3_t);
111   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, w4_t);
112   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, w5_t);
113   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, w6_t);
114   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, A, B, C, D, E, w7_t);
115   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, E, A, B, C, D, w8_t);
116   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, D, E, A, B, C, w9_t);
117   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, C, D, E, A, B, wa_t);
118   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, B, C, D, E, A, wb_t);
119
120   #undef K
121   #define K SHA1C03
122
123   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, wc_t);
124   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wd_t);
125   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, we_t);
126   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, wf_t);
127   w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w0_t);
128   w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w1_t);
129   w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w2_t);
130   w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w3_t);
131   w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w4_t);
132   w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, w5_t);
133   w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, w6_t);
134   w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, w7_t);
135   w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, w8_t);
136   w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, w9_t);
137   wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wa_t);
138   wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, A, B, C, D, E, wb_t);
139   wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, E, A, B, C, D, wc_t);
140   wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, D, E, A, B, C, wd_t);
141   we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, C, D, E, A, B, we_t);
142   wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, B, C, D, E, A, wf_t);
143
144   digest[0] += A;
145   digest[1] += B;
146   digest[2] += C;
147   digest[3] += D;
148   digest[4] += E;
149 }
150
151 static void hmac_sha1_pad (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[5], u32 opad[5])
152 {
153   w0[0] = w0[0] ^ 0x36363636;
154   w0[1] = w0[1] ^ 0x36363636;
155   w0[2] = w0[2] ^ 0x36363636;
156   w0[3] = w0[3] ^ 0x36363636;
157   w1[0] = w1[0] ^ 0x36363636;
158   w1[1] = w1[1] ^ 0x36363636;
159   w1[2] = w1[2] ^ 0x36363636;
160   w1[3] = w1[3] ^ 0x36363636;
161   w2[0] = w2[0] ^ 0x36363636;
162   w2[1] = w2[1] ^ 0x36363636;
163   w2[2] = w2[2] ^ 0x36363636;
164   w2[3] = w2[3] ^ 0x36363636;
165   w3[0] = w3[0] ^ 0x36363636;
166   w3[1] = w3[1] ^ 0x36363636;
167   w3[2] = w3[2] ^ 0x36363636;
168   w3[3] = w3[3] ^ 0x36363636;
169
170   ipad[0] = SHA1M_A;
171   ipad[1] = SHA1M_B;
172   ipad[2] = SHA1M_C;
173   ipad[3] = SHA1M_D;
174   ipad[4] = SHA1M_E;
175
176   sha1_transform (w0, w1, w2, w3, ipad);
177
178   w0[0] = w0[0] ^ 0x6a6a6a6a;
179   w0[1] = w0[1] ^ 0x6a6a6a6a;
180   w0[2] = w0[2] ^ 0x6a6a6a6a;
181   w0[3] = w0[3] ^ 0x6a6a6a6a;
182   w1[0] = w1[0] ^ 0x6a6a6a6a;
183   w1[1] = w1[1] ^ 0x6a6a6a6a;
184   w1[2] = w1[2] ^ 0x6a6a6a6a;
185   w1[3] = w1[3] ^ 0x6a6a6a6a;
186   w2[0] = w2[0] ^ 0x6a6a6a6a;
187   w2[1] = w2[1] ^ 0x6a6a6a6a;
188   w2[2] = w2[2] ^ 0x6a6a6a6a;
189   w2[3] = w2[3] ^ 0x6a6a6a6a;
190   w3[0] = w3[0] ^ 0x6a6a6a6a;
191   w3[1] = w3[1] ^ 0x6a6a6a6a;
192   w3[2] = w3[2] ^ 0x6a6a6a6a;
193   w3[3] = w3[3] ^ 0x6a6a6a6a;
194
195   opad[0] = SHA1M_A;
196   opad[1] = SHA1M_B;
197   opad[2] = SHA1M_C;
198   opad[3] = SHA1M_D;
199   opad[4] = SHA1M_E;
200
201   sha1_transform (w0, w1, w2, w3, opad);
202 }
203
204 static void hmac_sha1_run (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], u32 ipad[5], u32 opad[5], u32 digest[5])
205 {
206   digest[0] = ipad[0];
207   digest[1] = ipad[1];
208   digest[2] = ipad[2];
209   digest[3] = ipad[3];
210   digest[4] = ipad[4];
211
212   sha1_transform (w0, w1, w2, w3, digest);
213
214   w0[0] = digest[0];
215   w0[1] = digest[1];
216   w0[2] = digest[2];
217   w0[3] = digest[3];
218   w1[0] = digest[4];
219   w1[1] = 0x80000000;
220   w1[2] = 0;
221   w1[3] = 0;
222   w2[0] = 0;
223   w2[1] = 0;
224   w2[2] = 0;
225   w2[3] = 0;
226   w3[0] = 0;
227   w3[1] = 0;
228   w3[2] = 0;
229   w3[3] = (64 + 20) * 8;
230
231   digest[0] = opad[0];
232   digest[1] = opad[1];
233   digest[2] = opad[2];
234   digest[3] = opad[3];
235   digest[4] = opad[4];
236
237   sha1_transform (w0, w1, w2, w3, digest);
238 }
239
240 static void m00150m (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
241 {
242   /**
243    * modifier
244    */
245
246   const u32 gid = get_global_id (0);
247   const u32 lid = get_local_id (0);
248
249   /**
250    * salt
251    */
252
253   u32 salt_buf0[4];
254
255   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
256   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
257   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
258   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
259
260   u32 salt_buf1[4];
261
262   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
263   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
264   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
265   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
266
267   const u32 salt_len = salt_bufs[salt_pos].salt_len;
268
269   /**
270    * loop
271    */
272
273   u32 w0l = w0[0];
274
275   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
276   {
277     const u32 w0r = bfs_buf[il_pos].i;
278
279     w0[0] = w0l | w0r;
280
281     /**
282      * pads
283      */
284
285     u32 w0_t[4];
286
287     w0_t[0] = w0[0];
288     w0_t[1] = w0[1];
289     w0_t[2] = w0[2];
290     w0_t[3] = w0[3];
291
292     u32 w1_t[4];
293
294     w1_t[0] = w1[0];
295     w1_t[1] = w1[1];
296     w1_t[2] = w1[2];
297     w1_t[3] = w1[3];
298
299     u32 w2_t[4];
300
301     w2_t[0] = w2[0];
302     w2_t[1] = w2[1];
303     w2_t[2] = w2[2];
304     w2_t[3] = w2[3];
305
306     u32 w3_t[4];
307
308     w3_t[0] = w3[0];
309     w3_t[1] = w3[1];
310     w3_t[2] = 0;
311     w3_t[3] = 0;
312
313     u32 ipad[5];
314     u32 opad[5];
315
316     hmac_sha1_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
317
318     w0_t[0] = swap32 (salt_buf0[0]);
319     w0_t[1] = swap32 (salt_buf0[1]);
320     w0_t[2] = swap32 (salt_buf0[2]);
321     w0_t[3] = swap32 (salt_buf0[3]);
322     w1_t[0] = swap32 (salt_buf1[0]);
323     w1_t[1] = swap32 (salt_buf1[1]);
324     w1_t[2] = swap32 (salt_buf1[2]);
325     w1_t[3] = swap32 (salt_buf1[3]);
326     w2_t[0] = 0;
327     w2_t[1] = 0;
328     w2_t[2] = 0;
329     w2_t[3] = 0;
330     w3_t[0] = 0;
331     w3_t[1] = 0;
332     w3_t[2] = 0;
333     w3_t[3] = (64 + salt_len) * 8;
334
335     u32 digest[5];
336
337     hmac_sha1_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
338
339     const u32 r0 = digest[3];
340     const u32 r1 = digest[4];
341     const u32 r2 = digest[2];
342     const u32 r3 = digest[1];
343
344     #include COMPARE_M
345   }
346 }
347
348 static void m00150s (u32 w0[4], u32 w1[4], u32 w2[4], u32 w3[4], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset)
349 {
350   /**
351    * modifier
352    */
353
354   const u32 gid = get_global_id (0);
355   const u32 lid = get_local_id (0);
356
357   /**
358    * salt
359    */
360
361   u32 salt_buf0[4];
362
363   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[ 0];
364   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[ 1];
365   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[ 2];
366   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[ 3];
367
368   u32 salt_buf1[4];
369
370   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[ 4];
371   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[ 5];
372   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[ 6];
373   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[ 7];
374
375   const u32 salt_len = salt_bufs[salt_pos].salt_len;
376
377   /**
378    * digest
379    */
380
381   const u32 search[4] =
382   {
383     digests_buf[digests_offset].digest_buf[DGST_R0],
384     digests_buf[digests_offset].digest_buf[DGST_R1],
385     digests_buf[digests_offset].digest_buf[DGST_R2],
386     digests_buf[digests_offset].digest_buf[DGST_R3]
387   };
388
389   /**
390    * loop
391    */
392
393   u32 w0l = w0[0];
394
395   for (u32 il_pos = 0; il_pos < bfs_cnt; il_pos++)
396   {
397     const u32 w0r = bfs_buf[il_pos].i;
398
399     w0[0] = w0l | w0r;
400
401     /**
402      * pads
403      */
404
405     u32 w0_t[4];
406
407     w0_t[0] = w0[0];
408     w0_t[1] = w0[1];
409     w0_t[2] = w0[2];
410     w0_t[3] = w0[3];
411
412     u32 w1_t[4];
413
414     w1_t[0] = w1[0];
415     w1_t[1] = w1[1];
416     w1_t[2] = w1[2];
417     w1_t[3] = w1[3];
418
419     u32 w2_t[4];
420
421     w2_t[0] = w2[0];
422     w2_t[1] = w2[1];
423     w2_t[2] = w2[2];
424     w2_t[3] = w2[3];
425
426     u32 w3_t[4];
427
428     w3_t[0] = w3[0];
429     w3_t[1] = w3[1];
430     w3_t[2] = 0;
431     w3_t[3] = 0;
432
433     u32 ipad[5];
434     u32 opad[5];
435
436     hmac_sha1_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
437
438     w0_t[0] = swap32 (salt_buf0[0]);
439     w0_t[1] = swap32 (salt_buf0[1]);
440     w0_t[2] = swap32 (salt_buf0[2]);
441     w0_t[3] = swap32 (salt_buf0[3]);
442     w1_t[0] = swap32 (salt_buf1[0]);
443     w1_t[1] = swap32 (salt_buf1[1]);
444     w1_t[2] = swap32 (salt_buf1[2]);
445     w1_t[3] = swap32 (salt_buf1[3]);
446     w2_t[0] = 0;
447     w2_t[1] = 0;
448     w2_t[2] = 0;
449     w2_t[3] = 0;
450     w3_t[0] = 0;
451     w3_t[1] = 0;
452     w3_t[2] = 0;
453     w3_t[3] = (64 + salt_len) * 8;
454
455     u32 digest[5];
456
457     hmac_sha1_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
458
459     const u32 r0 = digest[3];
460     const u32 r1 = digest[4];
461     const u32 r2 = digest[2];
462     const u32 r3 = digest[1];
463
464     #include COMPARE_S
465   }
466 }
467
468 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00150_m04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
469 {
470   /**
471    * base
472    */
473
474   const u32 gid = get_global_id (0);
475
476   if (gid >= gid_max) return;
477
478   u32 w0[4];
479
480   w0[0] = pws[gid].i[ 0];
481   w0[1] = pws[gid].i[ 1];
482   w0[2] = pws[gid].i[ 2];
483   w0[3] = pws[gid].i[ 3];
484
485   u32 w1[4];
486
487   w1[0] = 0;
488   w1[1] = 0;
489   w1[2] = 0;
490   w1[3] = 0;
491
492   u32 w2[4];
493
494   w2[0] = 0;
495   w2[1] = 0;
496   w2[2] = 0;
497   w2[3] = 0;
498
499   u32 w3[4];
500
501   w3[0] = 0;
502   w3[1] = 0;
503   w3[2] = 0;
504   w3[3] = 0;
505
506   const u32 pw_len = pws[gid].pw_len;
507
508   /**
509    * main
510    */
511
512   m00150m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
513 }
514
515 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00150_m08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
516 {
517   /**
518    * base
519    */
520
521   const u32 gid = get_global_id (0);
522
523   if (gid >= gid_max) return;
524
525   u32 w0[4];
526
527   w0[0] = pws[gid].i[ 0];
528   w0[1] = pws[gid].i[ 1];
529   w0[2] = pws[gid].i[ 2];
530   w0[3] = pws[gid].i[ 3];
531
532   u32 w1[4];
533
534   w1[0] = pws[gid].i[ 4];
535   w1[1] = pws[gid].i[ 5];
536   w1[2] = pws[gid].i[ 6];
537   w1[3] = pws[gid].i[ 7];
538
539   u32 w2[4];
540
541   w2[0] = 0;
542   w2[1] = 0;
543   w2[2] = 0;
544   w2[3] = 0;
545
546   u32 w3[4];
547
548   w3[0] = 0;
549   w3[1] = 0;
550   w3[2] = 0;
551   w3[3] = 0;
552
553   const u32 pw_len = pws[gid].pw_len;
554
555   /**
556    * main
557    */
558
559   m00150m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
560 }
561
562 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00150_m16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
563 {
564   /**
565    * base
566    */
567
568   const u32 gid = get_global_id (0);
569
570   if (gid >= gid_max) return;
571
572   u32 w0[4];
573
574   w0[0] = pws[gid].i[ 0];
575   w0[1] = pws[gid].i[ 1];
576   w0[2] = pws[gid].i[ 2];
577   w0[3] = pws[gid].i[ 3];
578
579   u32 w1[4];
580
581   w1[0] = pws[gid].i[ 4];
582   w1[1] = pws[gid].i[ 5];
583   w1[2] = pws[gid].i[ 6];
584   w1[3] = pws[gid].i[ 7];
585
586   u32 w2[4];
587
588   w2[0] = pws[gid].i[ 8];
589   w2[1] = pws[gid].i[ 9];
590   w2[2] = pws[gid].i[10];
591   w2[3] = pws[gid].i[11];
592
593   u32 w3[4];
594
595   w3[0] = pws[gid].i[12];
596   w3[1] = pws[gid].i[13];
597   w3[2] = 0;
598   w3[3] = 0;
599
600   const u32 pw_len = pws[gid].pw_len;
601
602   /**
603    * main
604    */
605
606   m00150m (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
607 }
608
609 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00150_s04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
610 {
611   /**
612    * base
613    */
614
615   const u32 gid = get_global_id (0);
616
617   if (gid >= gid_max) return;
618
619   u32 w0[4];
620
621   w0[0] = pws[gid].i[ 0];
622   w0[1] = pws[gid].i[ 1];
623   w0[2] = pws[gid].i[ 2];
624   w0[3] = pws[gid].i[ 3];
625
626   u32 w1[4];
627
628   w1[0] = 0;
629   w1[1] = 0;
630   w1[2] = 0;
631   w1[3] = 0;
632
633   u32 w2[4];
634
635   w2[0] = 0;
636   w2[1] = 0;
637   w2[2] = 0;
638   w2[3] = 0;
639
640   u32 w3[4];
641
642   w3[0] = 0;
643   w3[1] = 0;
644   w3[2] = 0;
645   w3[3] = 0;
646
647   const u32 pw_len = pws[gid].pw_len;
648
649   /**
650    * main
651    */
652
653   m00150s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
654 }
655
656 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00150_s08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
657 {
658   /**
659    * base
660    */
661
662   const u32 gid = get_global_id (0);
663
664   if (gid >= gid_max) return;
665
666   u32 w0[4];
667
668   w0[0] = pws[gid].i[ 0];
669   w0[1] = pws[gid].i[ 1];
670   w0[2] = pws[gid].i[ 2];
671   w0[3] = pws[gid].i[ 3];
672
673   u32 w1[4];
674
675   w1[0] = pws[gid].i[ 4];
676   w1[1] = pws[gid].i[ 5];
677   w1[2] = pws[gid].i[ 6];
678   w1[3] = pws[gid].i[ 7];
679
680   u32 w2[4];
681
682   w2[0] = 0;
683   w2[1] = 0;
684   w2[2] = 0;
685   w2[3] = 0;
686
687   u32 w3[4];
688
689   w3[0] = 0;
690   w3[1] = 0;
691   w3[2] = 0;
692   w3[3] = 0;
693
694   const u32 pw_len = pws[gid].pw_len;
695
696   /**
697    * main
698    */
699
700   m00150s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
701 }
702
703 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00150_s16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 bfs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
704 {
705   /**
706    * base
707    */
708
709   const u32 gid = get_global_id (0);
710
711   if (gid >= gid_max) return;
712
713   u32 w0[4];
714
715   w0[0] = pws[gid].i[ 0];
716   w0[1] = pws[gid].i[ 1];
717   w0[2] = pws[gid].i[ 2];
718   w0[3] = pws[gid].i[ 3];
719
720   u32 w1[4];
721
722   w1[0] = pws[gid].i[ 4];
723   w1[1] = pws[gid].i[ 5];
724   w1[2] = pws[gid].i[ 6];
725   w1[3] = pws[gid].i[ 7];
726
727   u32 w2[4];
728
729   w2[0] = pws[gid].i[ 8];
730   w2[1] = pws[gid].i[ 9];
731   w2[2] = pws[gid].i[10];
732   w2[3] = pws[gid].i[11];
733
734   u32 w3[4];
735
736   w3[0] = pws[gid].i[12];
737   w3[1] = pws[gid].i[13];
738   w3[2] = 0;
739   w3[3] = 0;
740
741   const u32 pw_len = pws[gid].pw_len;
742
743   /**
744    * main
745    */
746
747   m00150s (w0, w1, w2, w3, pw_len, pws, rules_buf, combs_buf, bfs_buf, 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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
748 }