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