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