Initial commit
[hashcat.git] / amd / m00300_a3.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _SHA1_
7 #define _SCALAR_
8
9 #include "include/constants.h"
10 #include "include/kernel_vendor.h"
11
12 #ifdef  VLIW1
13 #define VECT_SIZE1
14 #endif
15
16 #ifdef  VLIW4
17 #define VECT_SIZE2
18 #endif
19
20 #ifdef  VLIW5
21 #define VECT_SIZE2
22 #endif
23
24 #define DGST_R0 3
25 #define DGST_R1 4
26 #define DGST_R2 2
27 #define DGST_R3 1
28
29 #include "include/kernel_functions.c"
30 #include "types_amd.c"
31 #include "common_amd.c"
32
33 #ifdef  VECT_SIZE1
34 #define VECT_COMPARE_S "check_single_vect1_comp4_warp.c"
35 #define VECT_COMPARE_M "check_multi_vect1_comp4_warp.c"
36 #endif
37
38 #ifdef  VECT_SIZE2
39 #define VECT_COMPARE_S "check_single_vect2_comp4_warp.c"
40 #define VECT_COMPARE_M "check_multi_vect2_comp4_warp.c"
41 #endif
42
43 #ifdef  VECT_SIZE4
44 #define VECT_COMPARE_S "check_single_vect4_comp4_warp.c"
45 #define VECT_COMPARE_M "check_multi_vect4_comp4_warp.c"
46 #endif
47
48 static void m00300m (u32 w[16], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
49 {
50   /**
51    * modifier
52    */
53
54   const u32 gid = get_global_id (0);
55   const u32 lid = get_local_id (0);
56
57   /**
58    * base
59    */
60
61   const u32 c_16s = rotl32 ((w[13] ^ w[ 8] ^ w[ 2]        ), 1u);
62   const u32 c_17s = rotl32 ((w[14] ^ w[ 9] ^ w[ 3] ^ w[ 1]), 1u);
63   const u32 c_18s = rotl32 ((w[15] ^ w[10] ^ w[ 4] ^ w[ 2]), 1u);
64   const u32 c_19s = rotl32 ((c_16s ^ w[11] ^ w[ 5] ^ w[ 3]), 1u);
65   const u32 c_20s = rotl32 ((c_17s ^ w[12] ^ w[ 6] ^ w[ 4]), 1u);
66   const u32 c_21s = rotl32 ((c_18s ^ w[13] ^ w[ 7] ^ w[ 5]), 1u);
67   const u32 c_22s = rotl32 ((c_19s ^ w[14] ^ w[ 8] ^ w[ 6]), 1u);
68   const u32 c_23s = rotl32 ((c_20s ^ w[15] ^ w[ 9] ^ w[ 7]), 1u);
69   const u32 c_24s = rotl32 ((c_21s ^ c_16s ^ w[10] ^ w[ 8]), 1u);
70   const u32 c_25s = rotl32 ((c_22s ^ c_17s ^ w[11] ^ w[ 9]), 1u);
71   const u32 c_26s = rotl32 ((c_23s ^ c_18s ^ w[12] ^ w[10]), 1u);
72   const u32 c_27s = rotl32 ((c_24s ^ c_19s ^ w[13] ^ w[11]), 1u);
73   const u32 c_28s = rotl32 ((c_25s ^ c_20s ^ w[14] ^ w[12]), 1u);
74   const u32 c_29s = rotl32 ((c_26s ^ c_21s ^ w[15] ^ w[13]), 1u);
75   const u32 c_30s = rotl32 ((c_27s ^ c_22s ^ c_16s ^ w[14]), 1u);
76   const u32 c_31s = rotl32 ((c_28s ^ c_23s ^ c_17s ^ w[15]), 1u);
77   const u32 c_32s = rotl32 ((c_29s ^ c_24s ^ c_18s ^ c_16s), 1u);
78   const u32 c_33s = rotl32 ((c_30s ^ c_25s ^ c_19s ^ c_17s), 1u);
79   const u32 c_34s = rotl32 ((c_31s ^ c_26s ^ c_20s ^ c_18s), 1u);
80   const u32 c_35s = rotl32 ((c_32s ^ c_27s ^ c_21s ^ c_19s), 1u);
81   const u32 c_36s = rotl32 ((c_33s ^ c_28s ^ c_22s ^ c_20s), 1u);
82   const u32 c_37s = rotl32 ((c_34s ^ c_29s ^ c_23s ^ c_21s), 1u);
83   const u32 c_38s = rotl32 ((c_35s ^ c_30s ^ c_24s ^ c_22s), 1u);
84   const u32 c_39s = rotl32 ((c_36s ^ c_31s ^ c_25s ^ c_23s), 1u);
85   const u32 c_40s = rotl32 ((c_37s ^ c_32s ^ c_26s ^ c_24s), 1u);
86   const u32 c_41s = rotl32 ((c_38s ^ c_33s ^ c_27s ^ c_25s), 1u);
87   const u32 c_42s = rotl32 ((c_39s ^ c_34s ^ c_28s ^ c_26s), 1u);
88   const u32 c_43s = rotl32 ((c_40s ^ c_35s ^ c_29s ^ c_27s), 1u);
89   const u32 c_44s = rotl32 ((c_41s ^ c_36s ^ c_30s ^ c_28s), 1u);
90   const u32 c_45s = rotl32 ((c_42s ^ c_37s ^ c_31s ^ c_29s), 1u);
91   const u32 c_46s = rotl32 ((c_43s ^ c_38s ^ c_32s ^ c_30s), 1u);
92   const u32 c_47s = rotl32 ((c_44s ^ c_39s ^ c_33s ^ c_31s), 1u);
93   const u32 c_48s = rotl32 ((c_45s ^ c_40s ^ c_34s ^ c_32s), 1u);
94   const u32 c_49s = rotl32 ((c_46s ^ c_41s ^ c_35s ^ c_33s), 1u);
95   const u32 c_50s = rotl32 ((c_47s ^ c_42s ^ c_36s ^ c_34s), 1u);
96   const u32 c_51s = rotl32 ((c_48s ^ c_43s ^ c_37s ^ c_35s), 1u);
97   const u32 c_52s = rotl32 ((c_49s ^ c_44s ^ c_38s ^ c_36s), 1u);
98   const u32 c_53s = rotl32 ((c_50s ^ c_45s ^ c_39s ^ c_37s), 1u);
99   const u32 c_54s = rotl32 ((c_51s ^ c_46s ^ c_40s ^ c_38s), 1u);
100   const u32 c_55s = rotl32 ((c_52s ^ c_47s ^ c_41s ^ c_39s), 1u);
101   const u32 c_56s = rotl32 ((c_53s ^ c_48s ^ c_42s ^ c_40s), 1u);
102   const u32 c_57s = rotl32 ((c_54s ^ c_49s ^ c_43s ^ c_41s), 1u);
103   const u32 c_58s = rotl32 ((c_55s ^ c_50s ^ c_44s ^ c_42s), 1u);
104   const u32 c_59s = rotl32 ((c_56s ^ c_51s ^ c_45s ^ c_43s), 1u);
105   const u32 c_60s = rotl32 ((c_57s ^ c_52s ^ c_46s ^ c_44s), 1u);
106   const u32 c_61s = rotl32 ((c_58s ^ c_53s ^ c_47s ^ c_45s), 1u);
107   const u32 c_62s = rotl32 ((c_59s ^ c_54s ^ c_48s ^ c_46s), 1u);
108   const u32 c_63s = rotl32 ((c_60s ^ c_55s ^ c_49s ^ c_47s), 1u);
109   const u32 c_64s = rotl32 ((c_61s ^ c_56s ^ c_50s ^ c_48s), 1u);
110   const u32 c_65s = rotl32 ((c_62s ^ c_57s ^ c_51s ^ c_49s), 1u);
111   const u32 c_66s = rotl32 ((c_63s ^ c_58s ^ c_52s ^ c_50s), 1u);
112   const u32 c_67s = rotl32 ((c_64s ^ c_59s ^ c_53s ^ c_51s), 1u);
113   const u32 c_68s = rotl32 ((c_65s ^ c_60s ^ c_54s ^ c_52s), 1u);
114   const u32 c_69s = rotl32 ((c_66s ^ c_61s ^ c_55s ^ c_53s), 1u);
115   const u32 c_70s = rotl32 ((c_67s ^ c_62s ^ c_56s ^ c_54s), 1u);
116   const u32 c_71s = rotl32 ((c_68s ^ c_63s ^ c_57s ^ c_55s), 1u);
117   const u32 c_72s = rotl32 ((c_69s ^ c_64s ^ c_58s ^ c_56s), 1u);
118   const u32 c_73s = rotl32 ((c_70s ^ c_65s ^ c_59s ^ c_57s), 1u);
119   const u32 c_74s = rotl32 ((c_71s ^ c_66s ^ c_60s ^ c_58s), 1u);
120   const u32 c_75s = rotl32 ((c_72s ^ c_67s ^ c_61s ^ c_59s), 1u);
121   const u32 c_76s = rotl32 ((c_73s ^ c_68s ^ c_62s ^ c_60s), 1u);
122   const u32 c_77s = rotl32 ((c_74s ^ c_69s ^ c_63s ^ c_61s), 1u);
123   const u32 c_78s = rotl32 ((c_75s ^ c_70s ^ c_64s ^ c_62s), 1u);
124   const u32 c_79s = rotl32 ((c_76s ^ c_71s ^ c_65s ^ c_63s), 1u);
125
126   const u32 c_17sK = c_17s + SHA1C00;
127   const u32 c_18sK = c_18s + SHA1C00;
128   const u32 c_20sK = c_20s + SHA1C01;
129   const u32 c_21sK = c_21s + SHA1C01;
130   const u32 c_23sK = c_23s + SHA1C01;
131   const u32 c_26sK = c_26s + SHA1C01;
132   const u32 c_27sK = c_27s + SHA1C01;
133   const u32 c_29sK = c_29s + SHA1C01;
134   const u32 c_33sK = c_33s + SHA1C01;
135   const u32 c_39sK = c_39s + SHA1C01;
136   const u32 c_41sK = c_41s + SHA1C02;
137   const u32 c_45sK = c_45s + SHA1C02;
138   const u32 c_53sK = c_53s + SHA1C02;
139   const u32 c_65sK = c_65s + SHA1C03;
140   const u32 c_69sK = c_69s + SHA1C03;
141
142   const u32 w1 = w[ 1] + SHA1C00;
143   const u32 w2 = w[ 2] + SHA1C00;
144   const u32 w3 = w[ 3] + SHA1C00;
145   const u32 w4 = w[ 4] + SHA1C00;
146   const u32 w5 = w[ 5] + SHA1C00;
147   const u32 w6 = w[ 6] + SHA1C00;
148   const u32 w7 = w[ 7] + SHA1C00;
149   const u32 w8 = w[ 8] + SHA1C00;
150   const u32 w9 = w[ 9] + SHA1C00;
151   const u32 wa = w[10] + SHA1C00;
152   const u32 wb = w[11] + SHA1C00;
153   const u32 wc = w[12] + SHA1C00;
154   const u32 wd = w[13] + SHA1C00;
155   const u32 we = w[14] + SHA1C00;
156   const u32 wf = w[15] + SHA1C00;
157
158  /**
159    * loop
160    */
161
162   const u32 bf_loops = ceil ((float) bfs_cnt / VECT_DIV);
163
164   u32x w0l = w[0];
165
166   for (u32 il_pos = 0; il_pos < bf_loops; il_pos++)
167   {
168     const u32x w0r = words_buf_r[il_pos];
169
170     const u32x w0 = w0l | w0r;
171
172     const u32x w0s01 = rotl32 (w0, 1u);
173     const u32x w0s02 = rotl32 (w0, 2u);
174     const u32x w0s03 = rotl32 (w0, 3u);
175     const u32x w0s04 = rotl32 (w0, 4u);
176     const u32x w0s05 = rotl32 (w0, 5u);
177     const u32x w0s06 = rotl32 (w0, 6u);
178     const u32x w0s07 = rotl32 (w0, 7u);
179     const u32x w0s08 = rotl32 (w0, 8u);
180     const u32x w0s09 = rotl32 (w0, 9u);
181     const u32x w0s10 = rotl32 (w0, 10u);
182     const u32x w0s11 = rotl32 (w0, 11u);
183     const u32x w0s12 = rotl32 (w0, 12u);
184     const u32x w0s13 = rotl32 (w0, 13u);
185     const u32x w0s14 = rotl32 (w0, 14u);
186     const u32x w0s15 = rotl32 (w0, 15u);
187     const u32x w0s16 = rotl32 (w0, 16u);
188     const u32x w0s17 = rotl32 (w0, 17u);
189     const u32x w0s18 = rotl32 (w0, 18u);
190     const u32x w0s19 = rotl32 (w0, 19u);
191     const u32x w0s20 = rotl32 (w0, 20u);
192     const u32x w0s21 = rotl32 (w0, 21u);
193     const u32x w0s22 = rotl32 (w0, 22U);
194
195     const u32x w0s04___w0s06 = w0s04 ^ w0s06;
196     const u32x w0s04___w0s08 = w0s04 ^ w0s08;
197     const u32x w0s08___w0s12 = w0s08 ^ w0s12;
198     const u32x w0s04___w0s06___w0s07 = w0s04___w0s06 ^ w0s07;
199
200     u32x a = SHA1M_A;
201     u32x b = SHA1M_B;
202     u32x c = SHA1M_C;
203     u32x d = SHA1M_D;
204     u32x e = SHA1M_E;
205
206     #undef K
207     #define K SHA1C00
208
209     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0);
210     SHA1_STEPX(SHA1_F0o, e, a, b, c, d, w1);
211     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, w2);
212     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, w3);
213     SHA1_STEPX(SHA1_F0o, b, c, d, e, a, w4);
214     SHA1_STEPX(SHA1_F0o, a, b, c, d, e, w5);
215     SHA1_STEPX(SHA1_F0o, e, a, b, c, d, w6);
216     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, w7);
217     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, w8);
218     SHA1_STEPX(SHA1_F0o, b, c, d, e, a, w9);
219     SHA1_STEPX(SHA1_F0o, a, b, c, d, e, wa);
220     SHA1_STEPX(SHA1_F0o, e, a, b, c, d, wb);
221     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, wc);
222     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, wd);
223     SHA1_STEPX(SHA1_F0o, b, c, d, e, a, we);
224     SHA1_STEPX(SHA1_F0o, a, b, c, d, e, wf);
225
226     SHA1_STEP (SHA1_F0o, e, a, b, c, d, (c_16s ^ w0s01));
227     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, (c_17sK));
228     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, (c_18sK));
229     SHA1_STEP (SHA1_F0o, b, c, d, e, a, (c_19s ^ w0s02));
230
231     #undef K
232     #define K SHA1C01
233
234     SHA1_STEPX(SHA1_F1 , a, b, c, d, e, (c_20sK));
235     SHA1_STEPX(SHA1_F1 , e, a, b, c, d, (c_21sK));
236     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_22s ^ w0s03));
237     SHA1_STEPX(SHA1_F1 , c, d, e, a, b, (c_23sK));
238     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_24s ^ w0s02));
239     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_25s ^ w0s04));
240     SHA1_STEPX(SHA1_F1 , e, a, b, c, d, (c_26sK));
241     SHA1_STEPX(SHA1_F1 , d, e, a, b, c, (c_27sK));
242     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_28s ^ w0s05));
243     SHA1_STEPX(SHA1_F1 , b, c, d, e, a, (c_29sK));
244     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_30s ^ w0s02 ^ w0s04));
245     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_31s ^ w0s06));
246     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_32s ^ w0s02 ^ w0s03));
247     SHA1_STEPX(SHA1_F1 , c, d, e, a, b, (c_33sK));
248     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_34s ^ w0s07));
249     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_35s ^ w0s04));
250     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_36s ^ w0s04___w0s06));
251     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_37s ^ w0s08));
252     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_38s ^ w0s04));
253     SHA1_STEPX(SHA1_F1 , b, c, d, e, a, (c_39sK));
254
255     #undef K
256     #define K SHA1C02
257
258     SHA1_STEP (SHA1_F2o, a, b, c, d, e, (c_40s ^ w0s04 ^ w0s09));
259     SHA1_STEPX(SHA1_F2o, e, a, b, c, d, (c_41sK));
260     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_42s ^ w0s06 ^ w0s08));
261     SHA1_STEP (SHA1_F2o, c, d, e, a, b, (c_43s ^ w0s10));
262     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_44s ^ w0s03 ^ w0s06 ^ w0s07));
263     SHA1_STEPX(SHA1_F2o, a, b, c, d, e, (c_45sK));
264     SHA1_STEP (SHA1_F2o, e, a, b, c, d, (c_46s ^ w0s04 ^ w0s11));
265     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_47s ^ w0s04___w0s08));
266     SHA1_STEP (SHA1_F2o, c, d, e, a, b, (c_48s ^ w0s03 ^ w0s04___w0s08 ^ w0s05 ^ w0s10));
267     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_49s ^ w0s12));
268     SHA1_STEP (SHA1_F2o, a, b, c, d, e, (c_50s ^ w0s08));
269     SHA1_STEP (SHA1_F2o, e, a, b, c, d, (c_51s ^ w0s04___w0s06));
270     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_52s ^ w0s04___w0s08 ^ w0s13));
271     SHA1_STEPX(SHA1_F2o, c, d, e, a, b, (c_53sK));
272     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_54s ^ w0s07 ^ w0s10 ^ w0s12));
273     SHA1_STEP (SHA1_F2o, a, b, c, d, e, (c_55s ^ w0s14));
274     SHA1_STEP (SHA1_F2o, e, a, b, c, d, (c_56s ^ w0s04___w0s06___w0s07 ^ w0s10 ^ w0s11));
275     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_57s ^ w0s08));
276     SHA1_STEP (SHA1_F2o, c, d, e, a, b, (c_58s ^ w0s04___w0s08 ^ w0s15));
277     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_59s ^ w0s08___w0s12));
278
279     #undef K
280     #define K SHA1C03
281
282     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_60s ^ w0s04 ^ w0s08___w0s12 ^ w0s07 ^ w0s14));
283     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_61s ^ w0s16));
284     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_62s ^ w0s04___w0s06 ^ w0s08___w0s12));
285     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_63s ^ w0s08));
286     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_64s ^ w0s04___w0s06___w0s07 ^ w0s08___w0s12 ^ w0s17));
287     SHA1_STEPX(SHA1_F1 , a, b, c, d, e, (c_65sK));
288     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_66s ^ w0s14 ^ w0s16));
289     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_67s ^ w0s08 ^ w0s18));
290     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_68s ^ w0s11 ^ w0s14 ^ w0s15));
291     SHA1_STEPX(SHA1_F1 , b, c, d, e, a, (c_69sK));
292     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_70s ^ w0s12 ^ w0s19));
293     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_71s ^ w0s12 ^ w0s16));
294     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_72s ^ w0s05 ^ w0s11 ^ w0s12 ^ w0s13 ^ w0s16 ^ w0s18));
295     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_73s ^ w0s20));
296     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_74s ^ w0s08 ^ w0s16));
297     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_75s ^ w0s06 ^ w0s12 ^ w0s14));
298     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_76s ^ w0s07 ^ w0s08___w0s12 ^ w0s16 ^ w0s21));
299     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_77s));
300     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_78s ^ w0s07 ^ w0s08 ^ w0s15 ^ w0s18 ^ w0s20));
301     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_79s ^ w0s08 ^ w0s22));
302
303     a += SHA1M_A;
304     b += SHA1M_B;
305     c += SHA1M_C;
306     d += SHA1M_D;
307     e += SHA1M_E;
308
309     u32x w0_t = a;
310     u32x w1_t = b;
311     u32x w2_t = c;
312     u32x w3_t = d;
313     u32x w4_t = e;
314     u32x w5_t = 0x80000000;
315     u32x w6_t = 0;
316     u32x w7_t = 0;
317     u32x w8_t = 0;
318     u32x w9_t = 0;
319     u32x wa_t = 0;
320     u32x wb_t = 0;
321     u32x wc_t = 0;
322     u32x wd_t = 0;
323     u32x we_t = 0;
324     u32x wf_t = 20 * 8;
325
326     a = SHA1M_A;
327     b = SHA1M_B;
328     c = SHA1M_C;
329     d = SHA1M_D;
330     e = SHA1M_E;
331
332     #undef K
333     #define K SHA1C00
334
335     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
336     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
337     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
338     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
339     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
340     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
341     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
342     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
343     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
344     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
345     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
346     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
347     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
348     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
349     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
350     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
351     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
352     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
353     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
354     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
355
356     #undef K
357     #define K SHA1C01
358
359     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
360     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
361     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
362     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
363     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
364     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
365     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
366     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
367     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
368     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
369     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
370     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
371     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
372     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
373     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
374     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
375     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
376     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
377     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
378     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
379
380     #undef K
381     #define K SHA1C02
382
383     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
384     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
385     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
386     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
387     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
388     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
389     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
390     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
391     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
392     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
393     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
394     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
395     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
396     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
397     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
398     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
399     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
400     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
401     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
402     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
403
404     #undef K
405     #define K SHA1C03
406
407     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
408     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
409     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
410     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
411     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
412     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
413     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
414     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
415     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
416     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
417     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
418     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
419     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
420     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
421     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
422     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
423     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
424     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
425     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
426     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
427
428
429     const u32x r0 = d;
430     const u32x r1 = e;
431     const u32x r2 = c;
432     const u32x r3 = b;
433
434     #include VECT_COMPARE_M
435   }
436 }
437
438 static void m00300s (u32 w[16], const u32 pw_len, __global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
439 {
440   /**
441    * modifier
442    */
443
444   const u32 gid = get_global_id (0);
445   const u32 lid = get_local_id (0);
446
447   /**
448    * base
449    */
450
451   const u32 c_16s = rotl32 ((w[13] ^ w[ 8] ^ w[ 2]        ), 1u);
452   const u32 c_17s = rotl32 ((w[14] ^ w[ 9] ^ w[ 3] ^ w[ 1]), 1u);
453   const u32 c_18s = rotl32 ((w[15] ^ w[10] ^ w[ 4] ^ w[ 2]), 1u);
454   const u32 c_19s = rotl32 ((c_16s ^ w[11] ^ w[ 5] ^ w[ 3]), 1u);
455   const u32 c_20s = rotl32 ((c_17s ^ w[12] ^ w[ 6] ^ w[ 4]), 1u);
456   const u32 c_21s = rotl32 ((c_18s ^ w[13] ^ w[ 7] ^ w[ 5]), 1u);
457   const u32 c_22s = rotl32 ((c_19s ^ w[14] ^ w[ 8] ^ w[ 6]), 1u);
458   const u32 c_23s = rotl32 ((c_20s ^ w[15] ^ w[ 9] ^ w[ 7]), 1u);
459   const u32 c_24s = rotl32 ((c_21s ^ c_16s ^ w[10] ^ w[ 8]), 1u);
460   const u32 c_25s = rotl32 ((c_22s ^ c_17s ^ w[11] ^ w[ 9]), 1u);
461   const u32 c_26s = rotl32 ((c_23s ^ c_18s ^ w[12] ^ w[10]), 1u);
462   const u32 c_27s = rotl32 ((c_24s ^ c_19s ^ w[13] ^ w[11]), 1u);
463   const u32 c_28s = rotl32 ((c_25s ^ c_20s ^ w[14] ^ w[12]), 1u);
464   const u32 c_29s = rotl32 ((c_26s ^ c_21s ^ w[15] ^ w[13]), 1u);
465   const u32 c_30s = rotl32 ((c_27s ^ c_22s ^ c_16s ^ w[14]), 1u);
466   const u32 c_31s = rotl32 ((c_28s ^ c_23s ^ c_17s ^ w[15]), 1u);
467   const u32 c_32s = rotl32 ((c_29s ^ c_24s ^ c_18s ^ c_16s), 1u);
468   const u32 c_33s = rotl32 ((c_30s ^ c_25s ^ c_19s ^ c_17s), 1u);
469   const u32 c_34s = rotl32 ((c_31s ^ c_26s ^ c_20s ^ c_18s), 1u);
470   const u32 c_35s = rotl32 ((c_32s ^ c_27s ^ c_21s ^ c_19s), 1u);
471   const u32 c_36s = rotl32 ((c_33s ^ c_28s ^ c_22s ^ c_20s), 1u);
472   const u32 c_37s = rotl32 ((c_34s ^ c_29s ^ c_23s ^ c_21s), 1u);
473   const u32 c_38s = rotl32 ((c_35s ^ c_30s ^ c_24s ^ c_22s), 1u);
474   const u32 c_39s = rotl32 ((c_36s ^ c_31s ^ c_25s ^ c_23s), 1u);
475   const u32 c_40s = rotl32 ((c_37s ^ c_32s ^ c_26s ^ c_24s), 1u);
476   const u32 c_41s = rotl32 ((c_38s ^ c_33s ^ c_27s ^ c_25s), 1u);
477   const u32 c_42s = rotl32 ((c_39s ^ c_34s ^ c_28s ^ c_26s), 1u);
478   const u32 c_43s = rotl32 ((c_40s ^ c_35s ^ c_29s ^ c_27s), 1u);
479   const u32 c_44s = rotl32 ((c_41s ^ c_36s ^ c_30s ^ c_28s), 1u);
480   const u32 c_45s = rotl32 ((c_42s ^ c_37s ^ c_31s ^ c_29s), 1u);
481   const u32 c_46s = rotl32 ((c_43s ^ c_38s ^ c_32s ^ c_30s), 1u);
482   const u32 c_47s = rotl32 ((c_44s ^ c_39s ^ c_33s ^ c_31s), 1u);
483   const u32 c_48s = rotl32 ((c_45s ^ c_40s ^ c_34s ^ c_32s), 1u);
484   const u32 c_49s = rotl32 ((c_46s ^ c_41s ^ c_35s ^ c_33s), 1u);
485   const u32 c_50s = rotl32 ((c_47s ^ c_42s ^ c_36s ^ c_34s), 1u);
486   const u32 c_51s = rotl32 ((c_48s ^ c_43s ^ c_37s ^ c_35s), 1u);
487   const u32 c_52s = rotl32 ((c_49s ^ c_44s ^ c_38s ^ c_36s), 1u);
488   const u32 c_53s = rotl32 ((c_50s ^ c_45s ^ c_39s ^ c_37s), 1u);
489   const u32 c_54s = rotl32 ((c_51s ^ c_46s ^ c_40s ^ c_38s), 1u);
490   const u32 c_55s = rotl32 ((c_52s ^ c_47s ^ c_41s ^ c_39s), 1u);
491   const u32 c_56s = rotl32 ((c_53s ^ c_48s ^ c_42s ^ c_40s), 1u);
492   const u32 c_57s = rotl32 ((c_54s ^ c_49s ^ c_43s ^ c_41s), 1u);
493   const u32 c_58s = rotl32 ((c_55s ^ c_50s ^ c_44s ^ c_42s), 1u);
494   const u32 c_59s = rotl32 ((c_56s ^ c_51s ^ c_45s ^ c_43s), 1u);
495   const u32 c_60s = rotl32 ((c_57s ^ c_52s ^ c_46s ^ c_44s), 1u);
496   const u32 c_61s = rotl32 ((c_58s ^ c_53s ^ c_47s ^ c_45s), 1u);
497   const u32 c_62s = rotl32 ((c_59s ^ c_54s ^ c_48s ^ c_46s), 1u);
498   const u32 c_63s = rotl32 ((c_60s ^ c_55s ^ c_49s ^ c_47s), 1u);
499   const u32 c_64s = rotl32 ((c_61s ^ c_56s ^ c_50s ^ c_48s), 1u);
500   const u32 c_65s = rotl32 ((c_62s ^ c_57s ^ c_51s ^ c_49s), 1u);
501   const u32 c_66s = rotl32 ((c_63s ^ c_58s ^ c_52s ^ c_50s), 1u);
502   const u32 c_67s = rotl32 ((c_64s ^ c_59s ^ c_53s ^ c_51s), 1u);
503   const u32 c_68s = rotl32 ((c_65s ^ c_60s ^ c_54s ^ c_52s), 1u);
504   const u32 c_69s = rotl32 ((c_66s ^ c_61s ^ c_55s ^ c_53s), 1u);
505   const u32 c_70s = rotl32 ((c_67s ^ c_62s ^ c_56s ^ c_54s), 1u);
506   const u32 c_71s = rotl32 ((c_68s ^ c_63s ^ c_57s ^ c_55s), 1u);
507   const u32 c_72s = rotl32 ((c_69s ^ c_64s ^ c_58s ^ c_56s), 1u);
508   const u32 c_73s = rotl32 ((c_70s ^ c_65s ^ c_59s ^ c_57s), 1u);
509   const u32 c_74s = rotl32 ((c_71s ^ c_66s ^ c_60s ^ c_58s), 1u);
510   const u32 c_75s = rotl32 ((c_72s ^ c_67s ^ c_61s ^ c_59s), 1u);
511
512   const u32 c_17sK = c_17s + SHA1C00;
513   const u32 c_18sK = c_18s + SHA1C00;
514   const u32 c_20sK = c_20s + SHA1C01;
515   const u32 c_21sK = c_21s + SHA1C01;
516   const u32 c_23sK = c_23s + SHA1C01;
517   const u32 c_26sK = c_26s + SHA1C01;
518   const u32 c_27sK = c_27s + SHA1C01;
519   const u32 c_29sK = c_29s + SHA1C01;
520   const u32 c_33sK = c_33s + SHA1C01;
521   const u32 c_39sK = c_39s + SHA1C01;
522   const u32 c_41sK = c_41s + SHA1C02;
523   const u32 c_45sK = c_45s + SHA1C02;
524   const u32 c_53sK = c_53s + SHA1C02;
525   const u32 c_65sK = c_65s + SHA1C03;
526   const u32 c_69sK = c_69s + SHA1C03;
527
528   const u32 w1 = w[ 1] + SHA1C00;
529   const u32 w2 = w[ 2] + SHA1C00;
530   const u32 w3 = w[ 3] + SHA1C00;
531   const u32 w4 = w[ 4] + SHA1C00;
532   const u32 w5 = w[ 5] + SHA1C00;
533   const u32 w6 = w[ 6] + SHA1C00;
534   const u32 w7 = w[ 7] + SHA1C00;
535   const u32 w8 = w[ 8] + SHA1C00;
536   const u32 w9 = w[ 9] + SHA1C00;
537   const u32 wa = w[10] + SHA1C00;
538   const u32 wb = w[11] + SHA1C00;
539   const u32 wc = w[12] + SHA1C00;
540   const u32 wd = w[13] + SHA1C00;
541   const u32 we = w[14] + SHA1C00;
542   const u32 wf = w[15] + SHA1C00;
543
544   /**
545    * digest
546    */
547
548   const u32 search[4] =
549   {
550     digests_buf[digests_offset].digest_buf[DGST_R0],
551     digests_buf[digests_offset].digest_buf[DGST_R1],
552     digests_buf[digests_offset].digest_buf[DGST_R2],
553     digests_buf[digests_offset].digest_buf[DGST_R3]
554   };
555
556   /**
557    * reverse
558    */
559
560   const u32 e_rev = rotl32 (search[1], 2u);
561
562  /**
563    * loop
564    */
565
566   const u32 bf_loops = ceil ((float) bfs_cnt / VECT_DIV);
567
568   u32x w0l = w[0];
569
570   for (u32 il_pos = 0; il_pos < bf_loops; il_pos++)
571   {
572     const u32x w0r = words_buf_r[il_pos];
573
574     const u32x w0 = w0l | w0r;
575
576     const u32x w0s01 = rotl32 (w0, 1u);
577     const u32x w0s02 = rotl32 (w0, 2u);
578     const u32x w0s03 = rotl32 (w0, 3u);
579     const u32x w0s04 = rotl32 (w0, 4u);
580     const u32x w0s05 = rotl32 (w0, 5u);
581     const u32x w0s06 = rotl32 (w0, 6u);
582     const u32x w0s07 = rotl32 (w0, 7u);
583     const u32x w0s08 = rotl32 (w0, 8u);
584     const u32x w0s09 = rotl32 (w0, 9u);
585     const u32x w0s10 = rotl32 (w0, 10u);
586     const u32x w0s11 = rotl32 (w0, 11u);
587     const u32x w0s12 = rotl32 (w0, 12u);
588     const u32x w0s13 = rotl32 (w0, 13u);
589     const u32x w0s14 = rotl32 (w0, 14u);
590     const u32x w0s15 = rotl32 (w0, 15u);
591     const u32x w0s16 = rotl32 (w0, 16u);
592     const u32x w0s17 = rotl32 (w0, 17u);
593     const u32x w0s18 = rotl32 (w0, 18u);
594     const u32x w0s19 = rotl32 (w0, 19u);
595     const u32x w0s20 = rotl32 (w0, 20u);
596
597     const u32x w0s04___w0s06 = w0s04 ^ w0s06;
598     const u32x w0s04___w0s08 = w0s04 ^ w0s08;
599     const u32x w0s08___w0s12 = w0s08 ^ w0s12;
600     const u32x w0s04___w0s06___w0s07 = w0s04___w0s06 ^ w0s07;
601
602     u32x a = SHA1M_A;
603     u32x b = SHA1M_B;
604     u32x c = SHA1M_C;
605     u32x d = SHA1M_D;
606     u32x e = SHA1M_E;
607
608     #undef K
609     #define K SHA1C00
610
611     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0);
612     SHA1_STEPX(SHA1_F0o, e, a, b, c, d, w1);
613     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, w2);
614     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, w3);
615     SHA1_STEPX(SHA1_F0o, b, c, d, e, a, w4);
616     SHA1_STEPX(SHA1_F0o, a, b, c, d, e, w5);
617     SHA1_STEPX(SHA1_F0o, e, a, b, c, d, w6);
618     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, w7);
619     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, w8);
620     SHA1_STEPX(SHA1_F0o, b, c, d, e, a, w9);
621     SHA1_STEPX(SHA1_F0o, a, b, c, d, e, wa);
622     SHA1_STEPX(SHA1_F0o, e, a, b, c, d, wb);
623     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, wc);
624     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, wd);
625     SHA1_STEPX(SHA1_F0o, b, c, d, e, a, we);
626     SHA1_STEPX(SHA1_F0o, a, b, c, d, e, wf);
627
628     SHA1_STEP (SHA1_F0o, e, a, b, c, d, (c_16s ^ w0s01));
629     SHA1_STEPX(SHA1_F0o, d, e, a, b, c, (c_17sK));
630     SHA1_STEPX(SHA1_F0o, c, d, e, a, b, (c_18sK));
631     SHA1_STEP (SHA1_F0o, b, c, d, e, a, (c_19s ^ w0s02));
632
633     #undef K
634     #define K SHA1C01
635
636     SHA1_STEPX(SHA1_F1 , a, b, c, d, e, (c_20sK));
637     SHA1_STEPX(SHA1_F1 , e, a, b, c, d, (c_21sK));
638     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_22s ^ w0s03));
639     SHA1_STEPX(SHA1_F1 , c, d, e, a, b, (c_23sK));
640     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_24s ^ w0s02));
641     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_25s ^ w0s04));
642     SHA1_STEPX(SHA1_F1 , e, a, b, c, d, (c_26sK));
643     SHA1_STEPX(SHA1_F1 , d, e, a, b, c, (c_27sK));
644     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_28s ^ w0s05));
645     SHA1_STEPX(SHA1_F1 , b, c, d, e, a, (c_29sK));
646     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_30s ^ w0s02 ^ w0s04));
647     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_31s ^ w0s06));
648     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_32s ^ w0s02 ^ w0s03));
649     SHA1_STEPX(SHA1_F1 , c, d, e, a, b, (c_33sK));
650     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_34s ^ w0s07));
651     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_35s ^ w0s04));
652     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_36s ^ w0s04___w0s06));
653     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_37s ^ w0s08));
654     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_38s ^ w0s04));
655     SHA1_STEPX(SHA1_F1 , b, c, d, e, a, (c_39sK));
656
657     #undef K
658     #define K SHA1C02
659
660     SHA1_STEP (SHA1_F2o, a, b, c, d, e, (c_40s ^ w0s04 ^ w0s09));
661     SHA1_STEPX(SHA1_F2o, e, a, b, c, d, (c_41sK));
662     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_42s ^ w0s06 ^ w0s08));
663     SHA1_STEP (SHA1_F2o, c, d, e, a, b, (c_43s ^ w0s10));
664     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_44s ^ w0s03 ^ w0s06 ^ w0s07));
665     SHA1_STEPX(SHA1_F2o, a, b, c, d, e, (c_45sK));
666     SHA1_STEP (SHA1_F2o, e, a, b, c, d, (c_46s ^ w0s04 ^ w0s11));
667     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_47s ^ w0s04___w0s08));
668     SHA1_STEP (SHA1_F2o, c, d, e, a, b, (c_48s ^ w0s03 ^ w0s04___w0s08 ^ w0s05 ^ w0s10));
669     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_49s ^ w0s12));
670     SHA1_STEP (SHA1_F2o, a, b, c, d, e, (c_50s ^ w0s08));
671     SHA1_STEP (SHA1_F2o, e, a, b, c, d, (c_51s ^ w0s04___w0s06));
672     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_52s ^ w0s04___w0s08 ^ w0s13));
673     SHA1_STEPX(SHA1_F2o, c, d, e, a, b, (c_53sK));
674     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_54s ^ w0s07 ^ w0s10 ^ w0s12));
675     SHA1_STEP (SHA1_F2o, a, b, c, d, e, (c_55s ^ w0s14));
676     SHA1_STEP (SHA1_F2o, e, a, b, c, d, (c_56s ^ w0s04___w0s06___w0s07 ^ w0s10 ^ w0s11));
677     SHA1_STEP (SHA1_F2o, d, e, a, b, c, (c_57s ^ w0s08));
678     SHA1_STEP (SHA1_F2o, c, d, e, a, b, (c_58s ^ w0s04___w0s08 ^ w0s15));
679     SHA1_STEP (SHA1_F2o, b, c, d, e, a, (c_59s ^ w0s08___w0s12));
680
681     #undef K
682     #define K SHA1C03
683
684     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_60s ^ w0s04 ^ w0s08___w0s12 ^ w0s07 ^ w0s14));
685     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_61s ^ w0s16));
686     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_62s ^ w0s04___w0s06 ^ w0s08___w0s12));
687     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_63s ^ w0s08));
688     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_64s ^ w0s04___w0s06___w0s07 ^ w0s08___w0s12 ^ w0s17));
689     SHA1_STEPX(SHA1_F1 , a, b, c, d, e, (c_65sK));
690     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_66s ^ w0s14 ^ w0s16));
691     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_67s ^ w0s08 ^ w0s18));
692     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_68s ^ w0s11 ^ w0s14 ^ w0s15));
693     SHA1_STEPX(SHA1_F1 , b, c, d, e, a, (c_69sK));
694     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_70s ^ w0s12 ^ w0s19));
695     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_71s ^ w0s12 ^ w0s16));
696     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_72s ^ w0s05 ^ w0s11 ^ w0s12 ^ w0s13 ^ w0s16 ^ w0s18));
697     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_73s ^ w0s20));
698     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_74s ^ w0s08 ^ w0s16));
699     SHA1_STEP (SHA1_F1 , a, b, c, d, e, (c_75s ^ w0s06 ^ w0s12 ^ w0s14));
700
701     const u32 c_76s = rotl32 ((c_73s ^ c_68s ^ c_62s ^ c_60s), 1u);
702     const u32 c_77s = rotl32 ((c_74s ^ c_69s ^ c_63s ^ c_61s), 1u);
703     const u32 c_78s = rotl32 ((c_75s ^ c_70s ^ c_64s ^ c_62s), 1u);
704     const u32 c_79s = rotl32 ((c_76s ^ c_71s ^ c_65s ^ c_63s), 1u);
705
706     const u32x w0s21 = rotl32 (w0, 21u);
707     const u32x w0s22 = rotl32 (w0, 22U);
708
709     SHA1_STEP (SHA1_F1 , e, a, b, c, d, (c_76s ^ w0s07 ^ w0s08___w0s12 ^ w0s16 ^ w0s21));
710     SHA1_STEP (SHA1_F1 , d, e, a, b, c, (c_77s));
711     SHA1_STEP (SHA1_F1 , c, d, e, a, b, (c_78s ^ w0s07 ^ w0s08 ^ w0s15 ^ w0s18 ^ w0s20));
712     SHA1_STEP (SHA1_F1 , b, c, d, e, a, (c_79s ^ w0s08 ^ w0s22));
713
714     a += SHA1M_A;
715     b += SHA1M_B;
716     c += SHA1M_C;
717     d += SHA1M_D;
718     e += SHA1M_E;
719
720     u32x w0_t = a;
721     u32x w1_t = b;
722     u32x w2_t = c;
723     u32x w3_t = d;
724     u32x w4_t = e;
725     u32x w5_t = 0x80000000;
726     u32x w6_t = 0;
727     u32x w7_t = 0;
728     u32x w8_t = 0;
729     u32x w9_t = 0;
730     u32x wa_t = 0;
731     u32x wb_t = 0;
732     u32x wc_t = 0;
733     u32x wd_t = 0;
734     u32x we_t = 0;
735     u32x wf_t = 20 * 8;
736
737     a = SHA1M_A;
738     b = SHA1M_B;
739     c = SHA1M_C;
740     d = SHA1M_D;
741     e = SHA1M_E;
742
743     #undef K
744     #define K SHA1C00
745
746     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w0_t);
747     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w1_t);
748     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w2_t);
749     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w3_t);
750     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w4_t);
751     SHA1_STEP (SHA1_F0o, a, b, c, d, e, w5_t);
752     SHA1_STEP (SHA1_F0o, e, a, b, c, d, w6_t);
753     SHA1_STEP (SHA1_F0o, d, e, a, b, c, w7_t);
754     SHA1_STEP (SHA1_F0o, c, d, e, a, b, w8_t);
755     SHA1_STEP (SHA1_F0o, b, c, d, e, a, w9_t);
756     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wa_t);
757     SHA1_STEP (SHA1_F0o, e, a, b, c, d, wb_t);
758     SHA1_STEP (SHA1_F0o, d, e, a, b, c, wc_t);
759     SHA1_STEP (SHA1_F0o, c, d, e, a, b, wd_t);
760     SHA1_STEP (SHA1_F0o, b, c, d, e, a, we_t);
761     SHA1_STEP (SHA1_F0o, a, b, c, d, e, wf_t);
762     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F0o, e, a, b, c, d, w0_t);
763     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F0o, d, e, a, b, c, w1_t);
764     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F0o, c, d, e, a, b, w2_t);
765     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F0o, b, c, d, e, a, w3_t);
766
767     #undef K
768     #define K SHA1C01
769
770     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w4_t);
771     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w5_t);
772     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w6_t);
773     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w7_t);
774     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w8_t);
775     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w9_t);
776     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wa_t);
777     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wb_t);
778     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wc_t);
779     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wd_t);
780     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, we_t);
781     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wf_t);
782     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w0_t);
783     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w1_t);
784     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w2_t);
785     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w3_t);
786     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w4_t);
787     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w5_t);
788     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w6_t);
789     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w7_t);
790
791     #undef K
792     #define K SHA1C02
793
794     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w8_t);
795     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w9_t);
796     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wa_t);
797     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wb_t);
798     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wc_t);
799     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, wd_t);
800     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, we_t);
801     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, wf_t);
802     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w0_t);
803     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w1_t);
804     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w2_t);
805     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w3_t);
806     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w4_t);
807     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, w5_t);
808     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, w6_t);
809     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F2o, a, b, c, d, e, w7_t);
810     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F2o, e, a, b, c, d, w8_t);
811     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F2o, d, e, a, b, c, w9_t);
812     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F2o, c, d, e, a, b, wa_t);
813     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F2o, b, c, d, e, a, wb_t);
814
815     #undef K
816     #define K SHA1C03
817
818     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wc_t);
819     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wd_t);
820     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, we_t);
821     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, wf_t);
822     w0_t = rotl32 ((wd_t ^ w8_t ^ w2_t ^ w0_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w0_t);
823     w1_t = rotl32 ((we_t ^ w9_t ^ w3_t ^ w1_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w1_t);
824     w2_t = rotl32 ((wf_t ^ wa_t ^ w4_t ^ w2_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w2_t);
825     w3_t = rotl32 ((w0_t ^ wb_t ^ w5_t ^ w3_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w3_t);
826     w4_t = rotl32 ((w1_t ^ wc_t ^ w6_t ^ w4_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w4_t);
827     w5_t = rotl32 ((w2_t ^ wd_t ^ w7_t ^ w5_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, w5_t);
828     w6_t = rotl32 ((w3_t ^ we_t ^ w8_t ^ w6_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, w6_t);
829     w7_t = rotl32 ((w4_t ^ wf_t ^ w9_t ^ w7_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, w7_t);
830     w8_t = rotl32 ((w5_t ^ w0_t ^ wa_t ^ w8_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, w8_t);
831     w9_t = rotl32 ((w6_t ^ w1_t ^ wb_t ^ w9_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, w9_t);
832     wa_t = rotl32 ((w7_t ^ w2_t ^ wc_t ^ wa_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wa_t);
833     wb_t = rotl32 ((w8_t ^ w3_t ^ wd_t ^ wb_t), 1u); SHA1_STEP (SHA1_F1, a, b, c, d, e, wb_t);
834
835     bool q_cond = allx (e_rev != e);
836
837     if (q_cond) continue;
838
839     wc_t = rotl32 ((w9_t ^ w4_t ^ we_t ^ wc_t), 1u); SHA1_STEP (SHA1_F1, e, a, b, c, d, wc_t);
840     wd_t = rotl32 ((wa_t ^ w5_t ^ wf_t ^ wd_t), 1u); SHA1_STEP (SHA1_F1, d, e, a, b, c, wd_t);
841     we_t = rotl32 ((wb_t ^ w6_t ^ w0_t ^ we_t), 1u); SHA1_STEP (SHA1_F1, c, d, e, a, b, we_t);
842     wf_t = rotl32 ((wc_t ^ w7_t ^ w1_t ^ wf_t), 1u); SHA1_STEP (SHA1_F1, b, c, d, e, a, wf_t);
843
844
845     const u32x r0 = d;
846     const u32x r1 = e;
847     const u32x r2 = c;
848     const u32x r3 = b;
849
850     #include VECT_COMPARE_S
851   }
852 }
853
854 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00300_m04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
855 {
856   /**
857    * base
858    */
859
860   const u32 gid = get_global_id (0);
861
862   if (gid >= gid_max) return;
863
864   u32 w[16];
865
866   w[ 0] = pws[gid].i[ 0];
867   w[ 1] = pws[gid].i[ 1];
868   w[ 2] = pws[gid].i[ 2];
869   w[ 3] = pws[gid].i[ 3];
870   w[ 4] = 0;
871   w[ 5] = 0;
872   w[ 6] = 0;
873   w[ 7] = 0;
874   w[ 8] = 0;
875   w[ 9] = 0;
876   w[10] = 0;
877   w[11] = 0;
878   w[12] = 0;
879   w[13] = 0;
880   w[14] = 0;
881   w[15] = pws[gid].i[15];
882
883   const u32 pw_len = pws[gid].pw_len;
884
885   /**
886    * main
887    */
888
889   m00300m (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
890 }
891
892 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00300_m08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
893 {
894   /**
895    * base
896    */
897
898   const u32 gid = get_global_id (0);
899
900   if (gid >= gid_max) return;
901
902   u32 w[16];
903
904   w[ 0] = pws[gid].i[ 0];
905   w[ 1] = pws[gid].i[ 1];
906   w[ 2] = pws[gid].i[ 2];
907   w[ 3] = pws[gid].i[ 3];
908   w[ 4] = pws[gid].i[ 4];
909   w[ 5] = pws[gid].i[ 5];
910   w[ 6] = pws[gid].i[ 6];
911   w[ 7] = pws[gid].i[ 7];
912   w[ 8] = 0;
913   w[ 9] = 0;
914   w[10] = 0;
915   w[11] = 0;
916   w[12] = 0;
917   w[13] = 0;
918   w[14] = 0;
919   w[15] = pws[gid].i[15];
920
921   const u32 pw_len = pws[gid].pw_len;
922
923   /**
924    * main
925    */
926
927   m00300m (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
928 }
929
930 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00300_m16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
931 {
932   /**
933    * base
934    */
935
936   const u32 gid = get_global_id (0);
937
938   if (gid >= gid_max) return;
939
940   u32 w[16];
941
942   w[ 0] = pws[gid].i[ 0];
943   w[ 1] = pws[gid].i[ 1];
944   w[ 2] = pws[gid].i[ 2];
945   w[ 3] = pws[gid].i[ 3];
946   w[ 4] = pws[gid].i[ 4];
947   w[ 5] = pws[gid].i[ 5];
948   w[ 6] = pws[gid].i[ 6];
949   w[ 7] = pws[gid].i[ 7];
950   w[ 8] = pws[gid].i[ 8];
951   w[ 9] = pws[gid].i[ 9];
952   w[10] = pws[gid].i[10];
953   w[11] = pws[gid].i[11];
954   w[12] = pws[gid].i[12];
955   w[13] = pws[gid].i[13];
956   w[14] = pws[gid].i[14];
957   w[15] = pws[gid].i[15];
958
959   const u32 pw_len = pws[gid].pw_len;
960
961   /**
962    * main
963    */
964
965   m00300m (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
966 }
967
968 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00300_s04 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
969 {
970   /**
971    * base
972    */
973
974   const u32 gid = get_global_id (0);
975
976   if (gid >= gid_max) return;
977
978   u32 w[16];
979
980   w[ 0] = pws[gid].i[ 0];
981   w[ 1] = pws[gid].i[ 1];
982   w[ 2] = pws[gid].i[ 2];
983   w[ 3] = pws[gid].i[ 3];
984   w[ 4] = 0;
985   w[ 5] = 0;
986   w[ 6] = 0;
987   w[ 7] = 0;
988   w[ 8] = 0;
989   w[ 9] = 0;
990   w[10] = 0;
991   w[11] = 0;
992   w[12] = 0;
993   w[13] = 0;
994   w[14] = 0;
995   w[15] = pws[gid].i[15];
996
997   const u32 pw_len = pws[gid].pw_len;
998
999   /**
1000    * main
1001    */
1002
1003   m00300s (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
1004 }
1005
1006 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00300_s08 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
1007 {
1008   /**
1009    * base
1010    */
1011
1012   const u32 gid = get_global_id (0);
1013
1014   if (gid >= gid_max) return;
1015
1016   u32 w[16];
1017
1018   w[ 0] = pws[gid].i[ 0];
1019   w[ 1] = pws[gid].i[ 1];
1020   w[ 2] = pws[gid].i[ 2];
1021   w[ 3] = pws[gid].i[ 3];
1022   w[ 4] = pws[gid].i[ 4];
1023   w[ 5] = pws[gid].i[ 5];
1024   w[ 6] = pws[gid].i[ 6];
1025   w[ 7] = pws[gid].i[ 7];
1026   w[ 8] = 0;
1027   w[ 9] = 0;
1028   w[10] = 0;
1029   w[11] = 0;
1030   w[12] = 0;
1031   w[13] = 0;
1032   w[14] = 0;
1033   w[15] = pws[gid].i[15];
1034
1035   const u32 pw_len = pws[gid].pw_len;
1036
1037   /**
1038    * main
1039    */
1040
1041   m00300s (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
1042 }
1043
1044 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m00300_s16 (__global pw_t *pws, __global gpu_rule_t *rules_buf, __global comb_t *combs_buf, __global 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_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)
1045 {
1046   /**
1047    * base
1048    */
1049
1050   const u32 gid = get_global_id (0);
1051
1052   if (gid >= gid_max) return;
1053
1054   u32 w[16];
1055
1056   w[ 0] = pws[gid].i[ 0];
1057   w[ 1] = pws[gid].i[ 1];
1058   w[ 2] = pws[gid].i[ 2];
1059   w[ 3] = pws[gid].i[ 3];
1060   w[ 4] = pws[gid].i[ 4];
1061   w[ 5] = pws[gid].i[ 5];
1062   w[ 6] = pws[gid].i[ 6];
1063   w[ 7] = pws[gid].i[ 7];
1064   w[ 8] = pws[gid].i[ 8];
1065   w[ 9] = pws[gid].i[ 9];
1066   w[10] = pws[gid].i[10];
1067   w[11] = pws[gid].i[11];
1068   w[12] = pws[gid].i[12];
1069   w[13] = pws[gid].i[13];
1070   w[14] = pws[gid].i[14];
1071   w[15] = pws[gid].i[15];
1072
1073   const u32 pw_len = pws[gid].pw_len;
1074
1075   /**
1076    * main
1077    */
1078
1079   m00300s (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_scryptV_buf, bitmap_mask, bitmap_shift1, bitmap_shift2, salt_pos, loop_pos, loop_cnt, bfs_cnt, digests_cnt, digests_offset);
1080 }