6f973a316d559968b0180d6c73d29a0151dd55de
[hashcat.git] / OpenCL / m01460_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _SHA256_
7
8 #define NEW_SIMD_CODE
9
10 #include "inc_hash_constants.h"
11 #include "inc_vendor.cl"
12
13 #define DGST_R0 3
14 #define DGST_R1 7
15 #define DGST_R2 2
16 #define DGST_R3 6
17
18 #include "inc_hash_functions.cl"
19 #include "inc_types.cl"
20 #include "inc_common.cl"
21 #include "inc_rp.h"
22 #include "inc_rp.cl"
23 #include "inc_simd.cl"
24
25 __constant u32 k_sha256[64] =
26 {
27   SHA256C00, SHA256C01, SHA256C02, SHA256C03,
28   SHA256C04, SHA256C05, SHA256C06, SHA256C07,
29   SHA256C08, SHA256C09, SHA256C0a, SHA256C0b,
30   SHA256C0c, SHA256C0d, SHA256C0e, SHA256C0f,
31   SHA256C10, SHA256C11, SHA256C12, SHA256C13,
32   SHA256C14, SHA256C15, SHA256C16, SHA256C17,
33   SHA256C18, SHA256C19, SHA256C1a, SHA256C1b,
34   SHA256C1c, SHA256C1d, SHA256C1e, SHA256C1f,
35   SHA256C20, SHA256C21, SHA256C22, SHA256C23,
36   SHA256C24, SHA256C25, SHA256C26, SHA256C27,
37   SHA256C28, SHA256C29, SHA256C2a, SHA256C2b,
38   SHA256C2c, SHA256C2d, SHA256C2e, SHA256C2f,
39   SHA256C30, SHA256C31, SHA256C32, SHA256C33,
40   SHA256C34, SHA256C35, SHA256C36, SHA256C37,
41   SHA256C38, SHA256C39, SHA256C3a, SHA256C3b,
42   SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f,
43 };
44
45 void sha256_transform (const u32x w0[4], const u32x w1[4], const u32x w2[4], const u32x w3[4], u32x digest[8])
46 {
47   u32x a = digest[0];
48   u32x b = digest[1];
49   u32x c = digest[2];
50   u32x d = digest[3];
51   u32x e = digest[4];
52   u32x f = digest[5];
53   u32x g = digest[6];
54   u32x h = digest[7];
55
56   u32x w0_t = w0[0];
57   u32x w1_t = w0[1];
58   u32x w2_t = w0[2];
59   u32x w3_t = w0[3];
60   u32x w4_t = w1[0];
61   u32x w5_t = w1[1];
62   u32x w6_t = w1[2];
63   u32x w7_t = w1[3];
64   u32x w8_t = w2[0];
65   u32x w9_t = w2[1];
66   u32x wa_t = w2[2];
67   u32x wb_t = w2[3];
68   u32x wc_t = w3[0];
69   u32x wd_t = w3[1];
70   u32x we_t = w3[2];
71   u32x wf_t = w3[3];
72
73   #define ROUND_EXPAND()                            \
74   {                                                 \
75     w0_t = SHA256_EXPAND (we_t, w9_t, w1_t, w0_t);  \
76     w1_t = SHA256_EXPAND (wf_t, wa_t, w2_t, w1_t);  \
77     w2_t = SHA256_EXPAND (w0_t, wb_t, w3_t, w2_t);  \
78     w3_t = SHA256_EXPAND (w1_t, wc_t, w4_t, w3_t);  \
79     w4_t = SHA256_EXPAND (w2_t, wd_t, w5_t, w4_t);  \
80     w5_t = SHA256_EXPAND (w3_t, we_t, w6_t, w5_t);  \
81     w6_t = SHA256_EXPAND (w4_t, wf_t, w7_t, w6_t);  \
82     w7_t = SHA256_EXPAND (w5_t, w0_t, w8_t, w7_t);  \
83     w8_t = SHA256_EXPAND (w6_t, w1_t, w9_t, w8_t);  \
84     w9_t = SHA256_EXPAND (w7_t, w2_t, wa_t, w9_t);  \
85     wa_t = SHA256_EXPAND (w8_t, w3_t, wb_t, wa_t);  \
86     wb_t = SHA256_EXPAND (w9_t, w4_t, wc_t, wb_t);  \
87     wc_t = SHA256_EXPAND (wa_t, w5_t, wd_t, wc_t);  \
88     wd_t = SHA256_EXPAND (wb_t, w6_t, we_t, wd_t);  \
89     we_t = SHA256_EXPAND (wc_t, w7_t, wf_t, we_t);  \
90     wf_t = SHA256_EXPAND (wd_t, w8_t, w0_t, wf_t);  \
91   }
92
93   #define ROUND_STEP(i)                                                                   \
94   {                                                                                       \
95     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w0_t, k_sha256[i +  0]); \
96     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w1_t, k_sha256[i +  1]); \
97     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, w2_t, k_sha256[i +  2]); \
98     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, w3_t, k_sha256[i +  3]); \
99     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, w4_t, k_sha256[i +  4]); \
100     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, w5_t, k_sha256[i +  5]); \
101     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, w6_t, k_sha256[i +  6]); \
102     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, w7_t, k_sha256[i +  7]); \
103     SHA256_STEP (SHA256_F0o, SHA256_F1o, a, b, c, d, e, f, g, h, w8_t, k_sha256[i +  8]); \
104     SHA256_STEP (SHA256_F0o, SHA256_F1o, h, a, b, c, d, e, f, g, w9_t, k_sha256[i +  9]); \
105     SHA256_STEP (SHA256_F0o, SHA256_F1o, g, h, a, b, c, d, e, f, wa_t, k_sha256[i + 10]); \
106     SHA256_STEP (SHA256_F0o, SHA256_F1o, f, g, h, a, b, c, d, e, wb_t, k_sha256[i + 11]); \
107     SHA256_STEP (SHA256_F0o, SHA256_F1o, e, f, g, h, a, b, c, d, wc_t, k_sha256[i + 12]); \
108     SHA256_STEP (SHA256_F0o, SHA256_F1o, d, e, f, g, h, a, b, c, wd_t, k_sha256[i + 13]); \
109     SHA256_STEP (SHA256_F0o, SHA256_F1o, c, d, e, f, g, h, a, b, we_t, k_sha256[i + 14]); \
110     SHA256_STEP (SHA256_F0o, SHA256_F1o, b, c, d, e, f, g, h, a, wf_t, k_sha256[i + 15]); \
111   }
112
113   ROUND_STEP (0);
114
115   #ifdef _unroll
116   #pragma unroll
117   #endif
118   for (int i = 16; i < 64; i += 16)
119   {
120     ROUND_EXPAND (); ROUND_STEP (i);
121   }
122
123   digest[0] += a;
124   digest[1] += b;
125   digest[2] += c;
126   digest[3] += d;
127   digest[4] += e;
128   digest[5] += f;
129   digest[6] += g;
130   digest[7] += h;
131 }
132
133 void hmac_sha256_pad (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[8], u32x opad[8])
134 {
135   w0[0] = w0[0] ^ 0x36363636;
136   w0[1] = w0[1] ^ 0x36363636;
137   w0[2] = w0[2] ^ 0x36363636;
138   w0[3] = w0[3] ^ 0x36363636;
139   w1[0] = w1[0] ^ 0x36363636;
140   w1[1] = w1[1] ^ 0x36363636;
141   w1[2] = w1[2] ^ 0x36363636;
142   w1[3] = w1[3] ^ 0x36363636;
143   w2[0] = w2[0] ^ 0x36363636;
144   w2[1] = w2[1] ^ 0x36363636;
145   w2[2] = w2[2] ^ 0x36363636;
146   w2[3] = w2[3] ^ 0x36363636;
147   w3[0] = w3[0] ^ 0x36363636;
148   w3[1] = w3[1] ^ 0x36363636;
149   w3[2] = w3[2] ^ 0x36363636;
150   w3[3] = w3[3] ^ 0x36363636;
151
152   ipad[0] = SHA256M_A;
153   ipad[1] = SHA256M_B;
154   ipad[2] = SHA256M_C;
155   ipad[3] = SHA256M_D;
156   ipad[4] = SHA256M_E;
157   ipad[5] = SHA256M_F;
158   ipad[6] = SHA256M_G;
159   ipad[7] = SHA256M_H;
160
161   sha256_transform (w0, w1, w2, w3, ipad);
162
163   w0[0] = w0[0] ^ 0x6a6a6a6a;
164   w0[1] = w0[1] ^ 0x6a6a6a6a;
165   w0[2] = w0[2] ^ 0x6a6a6a6a;
166   w0[3] = w0[3] ^ 0x6a6a6a6a;
167   w1[0] = w1[0] ^ 0x6a6a6a6a;
168   w1[1] = w1[1] ^ 0x6a6a6a6a;
169   w1[2] = w1[2] ^ 0x6a6a6a6a;
170   w1[3] = w1[3] ^ 0x6a6a6a6a;
171   w2[0] = w2[0] ^ 0x6a6a6a6a;
172   w2[1] = w2[1] ^ 0x6a6a6a6a;
173   w2[2] = w2[2] ^ 0x6a6a6a6a;
174   w2[3] = w2[3] ^ 0x6a6a6a6a;
175   w3[0] = w3[0] ^ 0x6a6a6a6a;
176   w3[1] = w3[1] ^ 0x6a6a6a6a;
177   w3[2] = w3[2] ^ 0x6a6a6a6a;
178   w3[3] = w3[3] ^ 0x6a6a6a6a;
179
180   opad[0] = SHA256M_A;
181   opad[1] = SHA256M_B;
182   opad[2] = SHA256M_C;
183   opad[3] = SHA256M_D;
184   opad[4] = SHA256M_E;
185   opad[5] = SHA256M_F;
186   opad[6] = SHA256M_G;
187   opad[7] = SHA256M_H;
188
189   sha256_transform (w0, w1, w2, w3, opad);
190 }
191
192 void hmac_sha256_run (u32x w0[4], u32x w1[4], u32x w2[4], u32x w3[4], u32x ipad[8], u32x opad[8], u32x digest[8])
193 {
194   digest[0] = ipad[0];
195   digest[1] = ipad[1];
196   digest[2] = ipad[2];
197   digest[3] = ipad[3];
198   digest[4] = ipad[4];
199   digest[5] = ipad[5];
200   digest[6] = ipad[6];
201   digest[7] = ipad[7];
202
203   sha256_transform (w0, w1, w2, w3, digest);
204
205   w0[0] = digest[0];
206   w0[1] = digest[1];
207   w0[2] = digest[2];
208   w0[3] = digest[3];
209   w1[0] = digest[4];
210   w1[1] = digest[5];
211   w1[2] = digest[6];
212   w1[3] = digest[7];
213   w2[0] = 0x80000000;
214   w2[1] = 0;
215   w2[2] = 0;
216   w2[3] = 0;
217   w3[0] = 0;
218   w3[1] = 0;
219   w3[2] = 0;
220   w3[3] = (64 + 32) * 8;
221
222   digest[0] = opad[0];
223   digest[1] = opad[1];
224   digest[2] = opad[2];
225   digest[3] = opad[3];
226   digest[4] = opad[4];
227   digest[5] = opad[5];
228   digest[6] = opad[6];
229   digest[7] = opad[7];
230
231   sha256_transform (w0, w1, w2, w3, digest);
232 }
233
234 __kernel void m01460_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_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
235 {
236   /**
237    * modifier
238    */
239
240   const u32 lid = get_local_id (0);
241
242   /**
243    * base
244    */
245
246   const u32 gid = get_global_id (0);
247
248   if (gid >= gid_max) return;
249
250   u32 pw_buf0[4];
251   u32 pw_buf1[4];
252
253   pw_buf0[0] = pws[gid].i[0];
254   pw_buf0[1] = pws[gid].i[1];
255   pw_buf0[2] = pws[gid].i[2];
256   pw_buf0[3] = pws[gid].i[3];
257   pw_buf1[0] = pws[gid].i[4];
258   pw_buf1[1] = pws[gid].i[5];
259   pw_buf1[2] = pws[gid].i[6];
260   pw_buf1[3] = pws[gid].i[7];
261
262   const u32 pw_len = pws[gid].pw_len;
263
264   /**
265    * salt
266    */
267
268   u32 salt_buf0[4];
269   u32 salt_buf1[4];
270   u32 salt_buf2[4];
271   u32 salt_buf3[4];
272
273   salt_buf0[0] = swap32_S (salt_bufs[salt_pos].salt_buf[ 0]);
274   salt_buf0[1] = swap32_S (salt_bufs[salt_pos].salt_buf[ 1]);
275   salt_buf0[2] = swap32_S (salt_bufs[salt_pos].salt_buf[ 2]);
276   salt_buf0[3] = swap32_S (salt_bufs[salt_pos].salt_buf[ 3]);
277   salt_buf1[0] = swap32_S (salt_bufs[salt_pos].salt_buf[ 4]);
278   salt_buf1[1] = swap32_S (salt_bufs[salt_pos].salt_buf[ 5]);
279   salt_buf1[2] = swap32_S (salt_bufs[salt_pos].salt_buf[ 6]);
280   salt_buf1[3] = swap32_S (salt_bufs[salt_pos].salt_buf[ 7]);
281   salt_buf2[0] = swap32_S (salt_bufs[salt_pos].salt_buf[ 8]);
282   salt_buf2[1] = swap32_S (salt_bufs[salt_pos].salt_buf[ 9]);
283   salt_buf2[2] = swap32_S (salt_bufs[salt_pos].salt_buf[10]);
284   salt_buf2[3] = swap32_S (salt_bufs[salt_pos].salt_buf[11]);
285   salt_buf3[0] = swap32_S (salt_bufs[salt_pos].salt_buf[12]);
286   salt_buf3[1] = swap32_S (salt_bufs[salt_pos].salt_buf[13]);
287   salt_buf3[2] = swap32_S (salt_bufs[salt_pos].salt_buf[14]);
288   salt_buf3[3] = swap32_S (salt_bufs[salt_pos].salt_buf[15]);
289
290   const u32 salt_len = salt_bufs[salt_pos].salt_len;
291
292   /**
293    * pads
294    */
295
296   u32x w0_t[4];
297   u32x w1_t[4];
298   u32x w2_t[4];
299   u32x w3_t[4];
300
301   w0_t[0] = salt_buf0[0];
302   w0_t[1] = salt_buf0[1];
303   w0_t[2] = salt_buf0[2];
304   w0_t[3] = salt_buf0[3];
305   w1_t[0] = salt_buf1[0];
306   w1_t[1] = salt_buf1[1];
307   w1_t[2] = salt_buf1[2];
308   w1_t[3] = salt_buf1[3];
309   w2_t[0] = salt_buf2[0];
310   w2_t[1] = salt_buf2[1];
311   w2_t[2] = salt_buf2[2];
312   w2_t[3] = salt_buf2[3];
313   w3_t[0] = salt_buf3[0];
314   w3_t[1] = salt_buf3[1];
315   w3_t[2] = salt_buf3[2];
316   w3_t[3] = salt_buf3[3];
317
318   u32x ipad[8];
319   u32x opad[8];
320
321   hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
322
323   /**
324    * loop
325    */
326
327   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
328   {
329     u32x w0[4] = { 0 };
330     u32x w1[4] = { 0 };
331     u32x w2[4] = { 0 };
332     u32x w3[4] = { 0 };
333
334     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
335
336     append_0x80_2x4_VV (w0, w1, out_len);
337
338     w0_t[0] = swap32 (w0[0]);
339     w0_t[1] = swap32 (w0[1]);
340     w0_t[2] = swap32 (w0[2]);
341     w0_t[3] = swap32 (w0[3]);
342     w1_t[0] = swap32 (w1[0]);
343     w1_t[1] = swap32 (w1[1]);
344     w1_t[2] = swap32 (w1[2]);
345     w1_t[3] = swap32 (w1[3]);
346     w2_t[0] = 0;
347     w2_t[1] = 0;
348     w2_t[2] = 0;
349     w2_t[3] = 0;
350     w3_t[0] = 0;
351     w3_t[1] = 0;
352     w3_t[2] = 0;
353     w3_t[3] = (64 + out_len) * 8;
354
355     u32x digest[8];
356
357     hmac_sha256_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
358
359     COMPARE_M_SIMD (digest[3], digest[7], digest[2], digest[6]);
360   }
361 }
362
363 __kernel void m01460_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_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
364 {
365 }
366
367 __kernel void m01460_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_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
368 {
369 }
370
371 __kernel void m01460_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_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
372 {
373   /**
374    * modifier
375    */
376
377   const u32 lid = get_local_id (0);
378
379   /**
380    * base
381    */
382
383   const u32 gid = get_global_id (0);
384
385   if (gid >= gid_max) return;
386
387   u32 pw_buf0[4];
388   u32 pw_buf1[4];
389
390   pw_buf0[0] = pws[gid].i[0];
391   pw_buf0[1] = pws[gid].i[1];
392   pw_buf0[2] = pws[gid].i[2];
393   pw_buf0[3] = pws[gid].i[3];
394   pw_buf1[0] = pws[gid].i[4];
395   pw_buf1[1] = pws[gid].i[5];
396   pw_buf1[2] = pws[gid].i[6];
397   pw_buf1[3] = pws[gid].i[7];
398
399   const u32 pw_len = pws[gid].pw_len;
400
401   /**
402    * salt
403    */
404
405   u32 salt_buf0[4];
406   u32 salt_buf1[4];
407   u32 salt_buf2[4];
408   u32 salt_buf3[4];
409
410   salt_buf0[0] = swap32_S (salt_bufs[salt_pos].salt_buf[ 0]);
411   salt_buf0[1] = swap32_S (salt_bufs[salt_pos].salt_buf[ 1]);
412   salt_buf0[2] = swap32_S (salt_bufs[salt_pos].salt_buf[ 2]);
413   salt_buf0[3] = swap32_S (salt_bufs[salt_pos].salt_buf[ 3]);
414   salt_buf1[0] = swap32_S (salt_bufs[salt_pos].salt_buf[ 4]);
415   salt_buf1[1] = swap32_S (salt_bufs[salt_pos].salt_buf[ 5]);
416   salt_buf1[2] = swap32_S (salt_bufs[salt_pos].salt_buf[ 6]);
417   salt_buf1[3] = swap32_S (salt_bufs[salt_pos].salt_buf[ 7]);
418   salt_buf2[0] = swap32_S (salt_bufs[salt_pos].salt_buf[ 8]);
419   salt_buf2[1] = swap32_S (salt_bufs[salt_pos].salt_buf[ 9]);
420   salt_buf2[2] = swap32_S (salt_bufs[salt_pos].salt_buf[10]);
421   salt_buf2[3] = swap32_S (salt_bufs[salt_pos].salt_buf[11]);
422   salt_buf3[0] = swap32_S (salt_bufs[salt_pos].salt_buf[12]);
423   salt_buf3[1] = swap32_S (salt_bufs[salt_pos].salt_buf[13]);
424   salt_buf3[2] = swap32_S (salt_bufs[salt_pos].salt_buf[14]);
425   salt_buf3[3] = swap32_S (salt_bufs[salt_pos].salt_buf[15]);
426
427   const u32 salt_len = salt_bufs[salt_pos].salt_len;
428
429   /**
430    * pads
431    */
432
433   u32x w0_t[4];
434   u32x w1_t[4];
435   u32x w2_t[4];
436   u32x w3_t[4];
437
438   w0_t[0] = salt_buf0[0];
439   w0_t[1] = salt_buf0[1];
440   w0_t[2] = salt_buf0[2];
441   w0_t[3] = salt_buf0[3];
442   w1_t[0] = salt_buf1[0];
443   w1_t[1] = salt_buf1[1];
444   w1_t[2] = salt_buf1[2];
445   w1_t[3] = salt_buf1[3];
446   w2_t[0] = salt_buf2[0];
447   w2_t[1] = salt_buf2[1];
448   w2_t[2] = salt_buf2[2];
449   w2_t[3] = salt_buf2[3];
450   w3_t[0] = salt_buf3[0];
451   w3_t[1] = salt_buf3[1];
452   w3_t[2] = salt_buf3[2];
453   w3_t[3] = salt_buf3[3];
454
455   u32x ipad[8];
456   u32x opad[8];
457
458   hmac_sha256_pad (w0_t, w1_t, w2_t, w3_t, ipad, opad);
459
460   /**
461    * digest
462    */
463
464   const u32 search[4] =
465   {
466     digests_buf[digests_offset].digest_buf[DGST_R0],
467     digests_buf[digests_offset].digest_buf[DGST_R1],
468     digests_buf[digests_offset].digest_buf[DGST_R2],
469     digests_buf[digests_offset].digest_buf[DGST_R3]
470   };
471
472   /**
473    * loop
474    */
475
476   for (u32 il_pos = 0; il_pos < il_cnt; il_pos += VECT_SIZE)
477   {
478     u32x w0[4] = { 0 };
479     u32x w1[4] = { 0 };
480     u32x w2[4] = { 0 };
481     u32x w3[4] = { 0 };
482
483     const u32x out_len = apply_rules_vect (pw_buf0, pw_buf1, pw_len, rules_buf, il_pos, w0, w1);
484
485     append_0x80_2x4_VV (w0, w1, out_len);
486
487     w0_t[0] = swap32 (w0[0]);
488     w0_t[1] = swap32 (w0[1]);
489     w0_t[2] = swap32 (w0[2]);
490     w0_t[3] = swap32 (w0[3]);
491     w1_t[0] = swap32 (w1[0]);
492     w1_t[1] = swap32 (w1[1]);
493     w1_t[2] = swap32 (w1[2]);
494     w1_t[3] = swap32 (w1[3]);
495     w2_t[0] = 0;
496     w2_t[1] = 0;
497     w2_t[2] = 0;
498     w2_t[3] = 0;
499     w3_t[0] = 0;
500     w3_t[1] = 0;
501     w3_t[2] = 0;
502     w3_t[3] = (64 + out_len) * 8;
503
504     u32x digest[8];
505
506     hmac_sha256_run (w0_t, w1_t, w2_t, w3_t, ipad, opad, digest);
507
508     COMPARE_S_SIMD (digest[3], digest[7], digest[2], digest[6]);
509   }
510 }
511
512 __kernel void m01460_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_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
513 {
514 }
515
516 __kernel void m01460_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_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 il_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
517 {
518 }