Replace the substring GPU to a more appropriate "device" or "kernel" substring depend...
[hashcat.git] / OpenCL / m03100_a0.cl
1 /**
2  * Author......: Jens Steube <jens.steube@gmail.com>
3  * License.....: MIT
4  */
5
6 #define _DES_
7
8 #include "include/constants.h"
9 #include "include/kernel_vendor.h"
10
11 #define DGST_R0 0
12 #define DGST_R1 1
13 #define DGST_R2 2
14 #define DGST_R3 3
15
16 #include "include/kernel_functions.c"
17 #include "OpenCL/types_ocl.c"
18 #include "OpenCL/common.c"
19 #include "include/rp_kernel.h"
20 #include "OpenCL/rp.c"
21
22 #define COMPARE_S "OpenCL/check_single_comp4.c"
23 #define COMPARE_M "OpenCL/check_multi_comp4.c"
24
25 #define PERM_OP(a,b,tt,n,m) \
26 {                           \
27   tt = a >> n;              \
28   tt = tt ^ b;              \
29   tt = tt & m;              \
30   b = b ^ tt;               \
31   tt = tt << n;             \
32   a = a ^ tt;               \
33 }
34
35 #define HPERM_OP(a,tt,n,m)  \
36 {                           \
37   tt = a << (16 + n);       \
38   tt = tt ^ a;              \
39   tt = tt & m;              \
40   a  = a ^ tt;              \
41   tt = tt >> (16 + n);      \
42   a  = a ^ tt;              \
43 }
44
45 #define IP(l,r,tt)                     \
46 {                                      \
47   PERM_OP (r, l, tt,  4, 0x0f0f0f0f);  \
48   PERM_OP (l, r, tt, 16, 0x0000ffff);  \
49   PERM_OP (r, l, tt,  2, 0x33333333);  \
50   PERM_OP (l, r, tt,  8, 0x00ff00ff);  \
51   PERM_OP (r, l, tt,  1, 0x55555555);  \
52 }
53
54 #define FP(l,r,tt)                     \
55 {                                      \
56   PERM_OP (l, r, tt,  1, 0x55555555);  \
57   PERM_OP (r, l, tt,  8, 0x00ff00ff);  \
58   PERM_OP (l, r, tt,  2, 0x33333333);  \
59   PERM_OP (r, l, tt, 16, 0x0000ffff);  \
60   PERM_OP (l, r, tt,  4, 0x0f0f0f0f);  \
61 }
62
63 __constant u32 c_SPtrans[8][64] =
64 {
65   {
66     0x02080800, 0x00080000, 0x02000002, 0x02080802,
67     0x02000000, 0x00080802, 0x00080002, 0x02000002,
68     0x00080802, 0x02080800, 0x02080000, 0x00000802,
69     0x02000802, 0x02000000, 0x00000000, 0x00080002,
70     0x00080000, 0x00000002, 0x02000800, 0x00080800,
71     0x02080802, 0x02080000, 0x00000802, 0x02000800,
72     0x00000002, 0x00000800, 0x00080800, 0x02080002,
73     0x00000800, 0x02000802, 0x02080002, 0x00000000,
74     0x00000000, 0x02080802, 0x02000800, 0x00080002,
75     0x02080800, 0x00080000, 0x00000802, 0x02000800,
76     0x02080002, 0x00000800, 0x00080800, 0x02000002,
77     0x00080802, 0x00000002, 0x02000002, 0x02080000,
78     0x02080802, 0x00080800, 0x02080000, 0x02000802,
79     0x02000000, 0x00000802, 0x00080002, 0x00000000,
80     0x00080000, 0x02000000, 0x02000802, 0x02080800,
81     0x00000002, 0x02080002, 0x00000800, 0x00080802,
82   },
83   {
84     0x40108010, 0x00000000, 0x00108000, 0x40100000,
85     0x40000010, 0x00008010, 0x40008000, 0x00108000,
86     0x00008000, 0x40100010, 0x00000010, 0x40008000,
87     0x00100010, 0x40108000, 0x40100000, 0x00000010,
88     0x00100000, 0x40008010, 0x40100010, 0x00008000,
89     0x00108010, 0x40000000, 0x00000000, 0x00100010,
90     0x40008010, 0x00108010, 0x40108000, 0x40000010,
91     0x40000000, 0x00100000, 0x00008010, 0x40108010,
92     0x00100010, 0x40108000, 0x40008000, 0x00108010,
93     0x40108010, 0x00100010, 0x40000010, 0x00000000,
94     0x40000000, 0x00008010, 0x00100000, 0x40100010,
95     0x00008000, 0x40000000, 0x00108010, 0x40008010,
96     0x40108000, 0x00008000, 0x00000000, 0x40000010,
97     0x00000010, 0x40108010, 0x00108000, 0x40100000,
98     0x40100010, 0x00100000, 0x00008010, 0x40008000,
99     0x40008010, 0x00000010, 0x40100000, 0x00108000,
100   },
101   {
102     0x04000001, 0x04040100, 0x00000100, 0x04000101,
103     0x00040001, 0x04000000, 0x04000101, 0x00040100,
104     0x04000100, 0x00040000, 0x04040000, 0x00000001,
105     0x04040101, 0x00000101, 0x00000001, 0x04040001,
106     0x00000000, 0x00040001, 0x04040100, 0x00000100,
107     0x00000101, 0x04040101, 0x00040000, 0x04000001,
108     0x04040001, 0x04000100, 0x00040101, 0x04040000,
109     0x00040100, 0x00000000, 0x04000000, 0x00040101,
110     0x04040100, 0x00000100, 0x00000001, 0x00040000,
111     0x00000101, 0x00040001, 0x04040000, 0x04000101,
112     0x00000000, 0x04040100, 0x00040100, 0x04040001,
113     0x00040001, 0x04000000, 0x04040101, 0x00000001,
114     0x00040101, 0x04000001, 0x04000000, 0x04040101,
115     0x00040000, 0x04000100, 0x04000101, 0x00040100,
116     0x04000100, 0x00000000, 0x04040001, 0x00000101,
117     0x04000001, 0x00040101, 0x00000100, 0x04040000,
118   },
119   {
120     0x00401008, 0x10001000, 0x00000008, 0x10401008,
121     0x00000000, 0x10400000, 0x10001008, 0x00400008,
122     0x10401000, 0x10000008, 0x10000000, 0x00001008,
123     0x10000008, 0x00401008, 0x00400000, 0x10000000,
124     0x10400008, 0x00401000, 0x00001000, 0x00000008,
125     0x00401000, 0x10001008, 0x10400000, 0x00001000,
126     0x00001008, 0x00000000, 0x00400008, 0x10401000,
127     0x10001000, 0x10400008, 0x10401008, 0x00400000,
128     0x10400008, 0x00001008, 0x00400000, 0x10000008,
129     0x00401000, 0x10001000, 0x00000008, 0x10400000,
130     0x10001008, 0x00000000, 0x00001000, 0x00400008,
131     0x00000000, 0x10400008, 0x10401000, 0x00001000,
132     0x10000000, 0x10401008, 0x00401008, 0x00400000,
133     0x10401008, 0x00000008, 0x10001000, 0x00401008,
134     0x00400008, 0x00401000, 0x10400000, 0x10001008,
135     0x00001008, 0x10000000, 0x10000008, 0x10401000,
136   },
137   {
138     0x08000000, 0x00010000, 0x00000400, 0x08010420,
139     0x08010020, 0x08000400, 0x00010420, 0x08010000,
140     0x00010000, 0x00000020, 0x08000020, 0x00010400,
141     0x08000420, 0x08010020, 0x08010400, 0x00000000,
142     0x00010400, 0x08000000, 0x00010020, 0x00000420,
143     0x08000400, 0x00010420, 0x00000000, 0x08000020,
144     0x00000020, 0x08000420, 0x08010420, 0x00010020,
145     0x08010000, 0x00000400, 0x00000420, 0x08010400,
146     0x08010400, 0x08000420, 0x00010020, 0x08010000,
147     0x00010000, 0x00000020, 0x08000020, 0x08000400,
148     0x08000000, 0x00010400, 0x08010420, 0x00000000,
149     0x00010420, 0x08000000, 0x00000400, 0x00010020,
150     0x08000420, 0x00000400, 0x00000000, 0x08010420,
151     0x08010020, 0x08010400, 0x00000420, 0x00010000,
152     0x00010400, 0x08010020, 0x08000400, 0x00000420,
153     0x00000020, 0x00010420, 0x08010000, 0x08000020,
154   },
155   {
156     0x80000040, 0x00200040, 0x00000000, 0x80202000,
157     0x00200040, 0x00002000, 0x80002040, 0x00200000,
158     0x00002040, 0x80202040, 0x00202000, 0x80000000,
159     0x80002000, 0x80000040, 0x80200000, 0x00202040,
160     0x00200000, 0x80002040, 0x80200040, 0x00000000,
161     0x00002000, 0x00000040, 0x80202000, 0x80200040,
162     0x80202040, 0x80200000, 0x80000000, 0x00002040,
163     0x00000040, 0x00202000, 0x00202040, 0x80002000,
164     0x00002040, 0x80000000, 0x80002000, 0x00202040,
165     0x80202000, 0x00200040, 0x00000000, 0x80002000,
166     0x80000000, 0x00002000, 0x80200040, 0x00200000,
167     0x00200040, 0x80202040, 0x00202000, 0x00000040,
168     0x80202040, 0x00202000, 0x00200000, 0x80002040,
169     0x80000040, 0x80200000, 0x00202040, 0x00000000,
170     0x00002000, 0x80000040, 0x80002040, 0x80202000,
171     0x80200000, 0x00002040, 0x00000040, 0x80200040,
172   },
173   {
174     0x00004000, 0x00000200, 0x01000200, 0x01000004,
175     0x01004204, 0x00004004, 0x00004200, 0x00000000,
176     0x01000000, 0x01000204, 0x00000204, 0x01004000,
177     0x00000004, 0x01004200, 0x01004000, 0x00000204,
178     0x01000204, 0x00004000, 0x00004004, 0x01004204,
179     0x00000000, 0x01000200, 0x01000004, 0x00004200,
180     0x01004004, 0x00004204, 0x01004200, 0x00000004,
181     0x00004204, 0x01004004, 0x00000200, 0x01000000,
182     0x00004204, 0x01004000, 0x01004004, 0x00000204,
183     0x00004000, 0x00000200, 0x01000000, 0x01004004,
184     0x01000204, 0x00004204, 0x00004200, 0x00000000,
185     0x00000200, 0x01000004, 0x00000004, 0x01000200,
186     0x00000000, 0x01000204, 0x01000200, 0x00004200,
187     0x00000204, 0x00004000, 0x01004204, 0x01000000,
188     0x01004200, 0x00000004, 0x00004004, 0x01004204,
189     0x01000004, 0x01004200, 0x01004000, 0x00004004,
190   },
191   {
192     0x20800080, 0x20820000, 0x00020080, 0x00000000,
193     0x20020000, 0x00800080, 0x20800000, 0x20820080,
194     0x00000080, 0x20000000, 0x00820000, 0x00020080,
195     0x00820080, 0x20020080, 0x20000080, 0x20800000,
196     0x00020000, 0x00820080, 0x00800080, 0x20020000,
197     0x20820080, 0x20000080, 0x00000000, 0x00820000,
198     0x20000000, 0x00800000, 0x20020080, 0x20800080,
199     0x00800000, 0x00020000, 0x20820000, 0x00000080,
200     0x00800000, 0x00020000, 0x20000080, 0x20820080,
201     0x00020080, 0x20000000, 0x00000000, 0x00820000,
202     0x20800080, 0x20020080, 0x20020000, 0x00800080,
203     0x20820000, 0x00000080, 0x00800080, 0x20020000,
204     0x20820080, 0x00800000, 0x20800000, 0x20000080,
205     0x00820000, 0x00020080, 0x20020080, 0x20800000,
206     0x00000080, 0x20820000, 0x00820080, 0x00000000,
207     0x20000000, 0x20800080, 0x00020000, 0x00820080,
208   }
209 };
210
211 __constant u32 c_skb[8][64] =
212 {
213   {
214     0x00000000, 0x00000010, 0x20000000, 0x20000010,
215     0x00010000, 0x00010010, 0x20010000, 0x20010010,
216     0x00000800, 0x00000810, 0x20000800, 0x20000810,
217     0x00010800, 0x00010810, 0x20010800, 0x20010810,
218     0x00000020, 0x00000030, 0x20000020, 0x20000030,
219     0x00010020, 0x00010030, 0x20010020, 0x20010030,
220     0x00000820, 0x00000830, 0x20000820, 0x20000830,
221     0x00010820, 0x00010830, 0x20010820, 0x20010830,
222     0x00080000, 0x00080010, 0x20080000, 0x20080010,
223     0x00090000, 0x00090010, 0x20090000, 0x20090010,
224     0x00080800, 0x00080810, 0x20080800, 0x20080810,
225     0x00090800, 0x00090810, 0x20090800, 0x20090810,
226     0x00080020, 0x00080030, 0x20080020, 0x20080030,
227     0x00090020, 0x00090030, 0x20090020, 0x20090030,
228     0x00080820, 0x00080830, 0x20080820, 0x20080830,
229     0x00090820, 0x00090830, 0x20090820, 0x20090830,
230   },
231   {
232     0x00000000, 0x02000000, 0x00002000, 0x02002000,
233     0x00200000, 0x02200000, 0x00202000, 0x02202000,
234     0x00000004, 0x02000004, 0x00002004, 0x02002004,
235     0x00200004, 0x02200004, 0x00202004, 0x02202004,
236     0x00000400, 0x02000400, 0x00002400, 0x02002400,
237     0x00200400, 0x02200400, 0x00202400, 0x02202400,
238     0x00000404, 0x02000404, 0x00002404, 0x02002404,
239     0x00200404, 0x02200404, 0x00202404, 0x02202404,
240     0x10000000, 0x12000000, 0x10002000, 0x12002000,
241     0x10200000, 0x12200000, 0x10202000, 0x12202000,
242     0x10000004, 0x12000004, 0x10002004, 0x12002004,
243     0x10200004, 0x12200004, 0x10202004, 0x12202004,
244     0x10000400, 0x12000400, 0x10002400, 0x12002400,
245     0x10200400, 0x12200400, 0x10202400, 0x12202400,
246     0x10000404, 0x12000404, 0x10002404, 0x12002404,
247     0x10200404, 0x12200404, 0x10202404, 0x12202404,
248   },
249   {
250     0x00000000, 0x00000001, 0x00040000, 0x00040001,
251     0x01000000, 0x01000001, 0x01040000, 0x01040001,
252     0x00000002, 0x00000003, 0x00040002, 0x00040003,
253     0x01000002, 0x01000003, 0x01040002, 0x01040003,
254     0x00000200, 0x00000201, 0x00040200, 0x00040201,
255     0x01000200, 0x01000201, 0x01040200, 0x01040201,
256     0x00000202, 0x00000203, 0x00040202, 0x00040203,
257     0x01000202, 0x01000203, 0x01040202, 0x01040203,
258     0x08000000, 0x08000001, 0x08040000, 0x08040001,
259     0x09000000, 0x09000001, 0x09040000, 0x09040001,
260     0x08000002, 0x08000003, 0x08040002, 0x08040003,
261     0x09000002, 0x09000003, 0x09040002, 0x09040003,
262     0x08000200, 0x08000201, 0x08040200, 0x08040201,
263     0x09000200, 0x09000201, 0x09040200, 0x09040201,
264     0x08000202, 0x08000203, 0x08040202, 0x08040203,
265     0x09000202, 0x09000203, 0x09040202, 0x09040203,
266   },
267   {
268     0x00000000, 0x00100000, 0x00000100, 0x00100100,
269     0x00000008, 0x00100008, 0x00000108, 0x00100108,
270     0x00001000, 0x00101000, 0x00001100, 0x00101100,
271     0x00001008, 0x00101008, 0x00001108, 0x00101108,
272     0x04000000, 0x04100000, 0x04000100, 0x04100100,
273     0x04000008, 0x04100008, 0x04000108, 0x04100108,
274     0x04001000, 0x04101000, 0x04001100, 0x04101100,
275     0x04001008, 0x04101008, 0x04001108, 0x04101108,
276     0x00020000, 0x00120000, 0x00020100, 0x00120100,
277     0x00020008, 0x00120008, 0x00020108, 0x00120108,
278     0x00021000, 0x00121000, 0x00021100, 0x00121100,
279     0x00021008, 0x00121008, 0x00021108, 0x00121108,
280     0x04020000, 0x04120000, 0x04020100, 0x04120100,
281     0x04020008, 0x04120008, 0x04020108, 0x04120108,
282     0x04021000, 0x04121000, 0x04021100, 0x04121100,
283     0x04021008, 0x04121008, 0x04021108, 0x04121108,
284   },
285   {
286     0x00000000, 0x10000000, 0x00010000, 0x10010000,
287     0x00000004, 0x10000004, 0x00010004, 0x10010004,
288     0x20000000, 0x30000000, 0x20010000, 0x30010000,
289     0x20000004, 0x30000004, 0x20010004, 0x30010004,
290     0x00100000, 0x10100000, 0x00110000, 0x10110000,
291     0x00100004, 0x10100004, 0x00110004, 0x10110004,
292     0x20100000, 0x30100000, 0x20110000, 0x30110000,
293     0x20100004, 0x30100004, 0x20110004, 0x30110004,
294     0x00001000, 0x10001000, 0x00011000, 0x10011000,
295     0x00001004, 0x10001004, 0x00011004, 0x10011004,
296     0x20001000, 0x30001000, 0x20011000, 0x30011000,
297     0x20001004, 0x30001004, 0x20011004, 0x30011004,
298     0x00101000, 0x10101000, 0x00111000, 0x10111000,
299     0x00101004, 0x10101004, 0x00111004, 0x10111004,
300     0x20101000, 0x30101000, 0x20111000, 0x30111000,
301     0x20101004, 0x30101004, 0x20111004, 0x30111004,
302   },
303   {
304     0x00000000, 0x08000000, 0x00000008, 0x08000008,
305     0x00000400, 0x08000400, 0x00000408, 0x08000408,
306     0x00020000, 0x08020000, 0x00020008, 0x08020008,
307     0x00020400, 0x08020400, 0x00020408, 0x08020408,
308     0x00000001, 0x08000001, 0x00000009, 0x08000009,
309     0x00000401, 0x08000401, 0x00000409, 0x08000409,
310     0x00020001, 0x08020001, 0x00020009, 0x08020009,
311     0x00020401, 0x08020401, 0x00020409, 0x08020409,
312     0x02000000, 0x0A000000, 0x02000008, 0x0A000008,
313     0x02000400, 0x0A000400, 0x02000408, 0x0A000408,
314     0x02020000, 0x0A020000, 0x02020008, 0x0A020008,
315     0x02020400, 0x0A020400, 0x02020408, 0x0A020408,
316     0x02000001, 0x0A000001, 0x02000009, 0x0A000009,
317     0x02000401, 0x0A000401, 0x02000409, 0x0A000409,
318     0x02020001, 0x0A020001, 0x02020009, 0x0A020009,
319     0x02020401, 0x0A020401, 0x02020409, 0x0A020409,
320   },
321   {
322     0x00000000, 0x00000100, 0x00080000, 0x00080100,
323     0x01000000, 0x01000100, 0x01080000, 0x01080100,
324     0x00000010, 0x00000110, 0x00080010, 0x00080110,
325     0x01000010, 0x01000110, 0x01080010, 0x01080110,
326     0x00200000, 0x00200100, 0x00280000, 0x00280100,
327     0x01200000, 0x01200100, 0x01280000, 0x01280100,
328     0x00200010, 0x00200110, 0x00280010, 0x00280110,
329     0x01200010, 0x01200110, 0x01280010, 0x01280110,
330     0x00000200, 0x00000300, 0x00080200, 0x00080300,
331     0x01000200, 0x01000300, 0x01080200, 0x01080300,
332     0x00000210, 0x00000310, 0x00080210, 0x00080310,
333     0x01000210, 0x01000310, 0x01080210, 0x01080310,
334     0x00200200, 0x00200300, 0x00280200, 0x00280300,
335     0x01200200, 0x01200300, 0x01280200, 0x01280300,
336     0x00200210, 0x00200310, 0x00280210, 0x00280310,
337     0x01200210, 0x01200310, 0x01280210, 0x01280310,
338   },
339   {
340     0x00000000, 0x04000000, 0x00040000, 0x04040000,
341     0x00000002, 0x04000002, 0x00040002, 0x04040002,
342     0x00002000, 0x04002000, 0x00042000, 0x04042000,
343     0x00002002, 0x04002002, 0x00042002, 0x04042002,
344     0x00000020, 0x04000020, 0x00040020, 0x04040020,
345     0x00000022, 0x04000022, 0x00040022, 0x04040022,
346     0x00002020, 0x04002020, 0x00042020, 0x04042020,
347     0x00002022, 0x04002022, 0x00042022, 0x04042022,
348     0x00000800, 0x04000800, 0x00040800, 0x04040800,
349     0x00000802, 0x04000802, 0x00040802, 0x04040802,
350     0x00002800, 0x04002800, 0x00042800, 0x04042800,
351     0x00002802, 0x04002802, 0x00042802, 0x04042802,
352     0x00000820, 0x04000820, 0x00040820, 0x04040820,
353     0x00000822, 0x04000822, 0x00040822, 0x04040822,
354     0x00002820, 0x04002820, 0x00042820, 0x04042820,
355     0x00002822, 0x04002822, 0x00042822, 0x04042822
356   }
357 };
358
359 #define BOX(i,n,S) (S)[(n)][(i)]
360
361 static void _des_crypt_encrypt (u32 iv[2], u32 data[2], u32 Kc[16], u32 Kd[16], __local u32 s_SPtrans[8][64])
362 {
363   u32 tt;
364
365   u32 r = data[0];
366   u32 l = data[1];
367
368   IP (r, l, tt);
369
370   r = rotl32 (r, 3u);
371   l = rotl32 (l, 3u);
372
373   #pragma unroll 16
374   for (u32 i = 0; i < 16; i += 2)
375   {
376     u32 u;
377     u32 t;
378
379     u = Kc[i + 0] ^ r;
380     t = Kd[i + 0] ^ rotl32 (r, 28u);
381
382     l ^= BOX (((u >>  2) & 0x3f), 0, s_SPtrans)
383        | BOX (((u >> 10) & 0x3f), 2, s_SPtrans)
384        | BOX (((u >> 18) & 0x3f), 4, s_SPtrans)
385        | BOX (((u >> 26) & 0x3f), 6, s_SPtrans)
386        | BOX (((t >>  2) & 0x3f), 1, s_SPtrans)
387        | BOX (((t >> 10) & 0x3f), 3, s_SPtrans)
388        | BOX (((t >> 18) & 0x3f), 5, s_SPtrans)
389        | BOX (((t >> 26) & 0x3f), 7, s_SPtrans);
390
391     u = Kc[i + 1] ^ l;
392     t = Kd[i + 1] ^ rotl32 (l, 28u);
393
394     r ^= BOX (((u >>  2) & 0x3f), 0, s_SPtrans)
395        | BOX (((u >> 10) & 0x3f), 2, s_SPtrans)
396        | BOX (((u >> 18) & 0x3f), 4, s_SPtrans)
397        | BOX (((u >> 26) & 0x3f), 6, s_SPtrans)
398        | BOX (((t >>  2) & 0x3f), 1, s_SPtrans)
399        | BOX (((t >> 10) & 0x3f), 3, s_SPtrans)
400        | BOX (((t >> 18) & 0x3f), 5, s_SPtrans)
401        | BOX (((t >> 26) & 0x3f), 7, s_SPtrans);
402   }
403
404   l = rotl32 (l, 29u);
405   r = rotl32 (r, 29u);
406
407   FP (r, l, tt);
408
409   iv[0] = l;
410   iv[1] = r;
411 }
412
413 static void _des_crypt_keysetup (u32 c, u32 d, u32 Kc[16], u32 Kd[16], __local u32 s_skb[8][64])
414 {
415   u32 tt;
416
417   PERM_OP  (d, c, tt, 4, 0x0f0f0f0f);
418   HPERM_OP (c,    tt, 2, 0xcccc0000);
419   HPERM_OP (d,    tt, 2, 0xcccc0000);
420   PERM_OP  (d, c, tt, 1, 0x55555555);
421   PERM_OP  (c, d, tt, 8, 0x00ff00ff);
422   PERM_OP  (d, c, tt, 1, 0x55555555);
423
424   d = ((d & 0x000000ff) << 16)
425     | ((d & 0x0000ff00) <<  0)
426     | ((d & 0x00ff0000) >> 16)
427     | ((c & 0xf0000000) >>  4);
428
429   c = c & 0x0fffffff;
430
431   #pragma unroll 16
432   for (u32 i = 0; i < 16; i++)
433   {
434     if ((i < 2) || (i == 8) || (i == 15))
435     {
436       c = ((c >> 1) | (c << 27));
437       d = ((d >> 1) | (d << 27));
438     }
439     else
440     {
441       c = ((c >> 2) | (c << 26));
442       d = ((d >> 2) | (d << 26));
443     }
444
445     c = c & 0x0fffffff;
446     d = d & 0x0fffffff;
447
448     const u32 c00 = (c >>  0) & 0x0000003f;
449     const u32 c06 = (c >>  6) & 0x00383003;
450     const u32 c07 = (c >>  7) & 0x0000003c;
451     const u32 c13 = (c >> 13) & 0x0000060f;
452     const u32 c20 = (c >> 20) & 0x00000001;
453
454     u32 s = BOX (((c00 >>  0) & 0xff), 0, s_skb)
455           | BOX (((c06 >>  0) & 0xff)
456                 |((c07 >>  0) & 0xff), 1, s_skb)
457           | BOX (((c13 >>  0) & 0xff)
458                 |((c06 >>  8) & 0xff), 2, s_skb)
459           | BOX (((c20 >>  0) & 0xff)
460                 |((c13 >>  8) & 0xff)
461                 |((c06 >> 16) & 0xff), 3, s_skb);
462
463     const u32 d00 = (d >>  0) & 0x00003c3f;
464     const u32 d07 = (d >>  7) & 0x00003f03;
465     const u32 d21 = (d >> 21) & 0x0000000f;
466     const u32 d22 = (d >> 22) & 0x00000030;
467
468     u32 t = BOX (((d00 >>  0) & 0xff), 4, s_skb)
469           | BOX (((d07 >>  0) & 0xff)
470                 |((d00 >>  8) & 0xff), 5, s_skb)
471           | BOX (((d07 >>  8) & 0xff), 6, s_skb)
472           | BOX (((d21 >>  0) & 0xff)
473                 |((d22 >>  0) & 0xff), 7, s_skb);
474
475     Kc[i] = ((t << 16) | (s & 0x0000ffff));
476     Kd[i] = ((s >> 16) | (t & 0xffff0000));
477
478     Kc[i] = rotl32 (Kc[i], 2u);
479     Kd[i] = rotl32 (Kd[i], 2u);
480   }
481 }
482
483 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03100_m04 (__global pw_t *pws, __global kernel_rule_t *  rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
484 {
485   /**
486    * modifier
487    */
488
489   const u32 lid = get_local_id (0);
490
491   /**
492    * base
493    */
494
495   const u32 gid = get_global_id (0);
496
497   u32 pw_buf0[4];
498
499   pw_buf0[0] = pws[gid].i[ 0];
500   pw_buf0[1] = pws[gid].i[ 1];
501   pw_buf0[2] = pws[gid].i[ 2];
502   pw_buf0[3] = pws[gid].i[ 3];
503
504   u32 pw_buf1[4];
505
506   pw_buf1[0] = pws[gid].i[ 4];
507   pw_buf1[1] = pws[gid].i[ 5];
508   pw_buf1[2] = pws[gid].i[ 6];
509   pw_buf1[3] = pws[gid].i[ 7];
510
511   const u32 pw_len = pws[gid].pw_len;
512
513   /**
514    * sbox, kbox
515    */
516
517   __local u32 s_SPtrans[8][64];
518   __local u32 s_skb[8][64];
519
520   s_SPtrans[0][lid] = c_SPtrans[0][lid];
521   s_SPtrans[1][lid] = c_SPtrans[1][lid];
522   s_SPtrans[2][lid] = c_SPtrans[2][lid];
523   s_SPtrans[3][lid] = c_SPtrans[3][lid];
524   s_SPtrans[4][lid] = c_SPtrans[4][lid];
525   s_SPtrans[5][lid] = c_SPtrans[5][lid];
526   s_SPtrans[6][lid] = c_SPtrans[6][lid];
527   s_SPtrans[7][lid] = c_SPtrans[7][lid];
528
529   s_skb[0][lid] = c_skb[0][lid];
530   s_skb[1][lid] = c_skb[1][lid];
531   s_skb[2][lid] = c_skb[2][lid];
532   s_skb[3][lid] = c_skb[3][lid];
533   s_skb[4][lid] = c_skb[4][lid];
534   s_skb[5][lid] = c_skb[5][lid];
535   s_skb[6][lid] = c_skb[6][lid];
536   s_skb[7][lid] = c_skb[7][lid];
537
538   barrier (CLK_LOCAL_MEM_FENCE);
539
540   if (gid >= gid_max) return;
541
542   /**
543    * salt
544    */
545
546   u32 salt_buf0[4];
547
548   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0];
549   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1];
550   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2];
551   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[3];
552
553   u32 salt_buf1[4];
554
555   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[4];
556   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[5];
557   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[6];
558   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[7];
559
560   const u32 salt_len = salt_bufs[salt_pos].salt_len;
561
562   /**
563    * loop
564    */
565
566   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
567   {
568     u32 w0[4];
569
570     w0[0] = pw_buf0[0];
571     w0[1] = pw_buf0[1];
572     w0[2] = pw_buf0[2];
573     w0[3] = pw_buf0[3];
574
575     u32 w1[4];
576
577     w1[0] = pw_buf1[0];
578     w1[1] = pw_buf1[1];
579     w1[2] = pw_buf1[2];
580     w1[3] = pw_buf1[3];
581
582     u32 w2[4];
583
584     w2[0] = 0;
585     w2[1] = 0;
586     w2[2] = 0;
587     w2[3] = 0;
588
589     u32 w3[4];
590
591     w3[0] = 0;
592     w3[1] = 0;
593     w3[2] = 0;
594     w3[3] = 0;
595
596     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
597
598     const u32 salt_word_len = (salt_len + out_len) * 2;
599
600     /**
601      * prepend salt
602      */
603
604     u32 w0_t[4];
605
606     w0_t[0] = w0[0];
607     w0_t[1] = w0[1];
608     w0_t[2] = w0[2];
609     w0_t[3] = w0[3];
610
611     u32 w1_t[4];
612
613     w1_t[0] = w1[0];
614     w1_t[1] = w1[1];
615     w1_t[2] = w1[2];
616     w1_t[3] = w1[3];
617
618     u32 w2_t[4];
619
620     w2_t[0] = w2[0];
621     w2_t[1] = w2[1];
622     w2_t[2] = w2[2];
623     w2_t[3] = w2[3];
624
625     u32 w3_t[4];
626
627     w3_t[0] = w3[0];
628     w3_t[1] = w3[1];
629     w3_t[2] = w3[2];
630     w3_t[3] = w3[3];
631
632     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
633
634     w0_t[0] |= salt_buf0[0];
635     w0_t[1] |= salt_buf0[1];
636     w0_t[2] |= salt_buf0[2];
637     w0_t[3] |= salt_buf0[3];
638     w1_t[0] |= salt_buf1[0];
639     w1_t[1] |= salt_buf1[1];
640     w1_t[2] |= salt_buf1[2];
641     w1_t[3] |= salt_buf1[3];
642
643     u32 dst[16];
644
645     dst[ 0] = w0_t[0];
646     dst[ 1] = w0_t[1];
647     dst[ 2] = w0_t[2];
648     dst[ 3] = w0_t[3];
649     dst[ 4] = w1_t[0];
650     dst[ 5] = w1_t[1];
651     dst[ 6] = w1_t[2];
652     dst[ 7] = w1_t[3];
653     dst[ 8] = w2_t[0];
654     dst[ 9] = w2_t[1];
655     dst[10] = w2_t[2];
656     dst[11] = w2_t[3];
657     dst[12] = 0;
658     dst[13] = 0;
659     dst[14] = 0;
660     dst[15] = 0;
661
662     /**
663      * precompute key1 since key is static: 0x0123456789abcdef
664      * plus LEFT_ROTATE by 2
665      */
666
667     u32 Kc[16];
668
669     Kc[ 0] = 0x64649040;
670     Kc[ 1] = 0x14909858;
671     Kc[ 2] = 0xc4b44888;
672     Kc[ 3] = 0x9094e438;
673     Kc[ 4] = 0xd8a004f0;
674     Kc[ 5] = 0xa8f02810;
675     Kc[ 6] = 0xc84048d8;
676     Kc[ 7] = 0x68d804a8;
677     Kc[ 8] = 0x0490e40c;
678     Kc[ 9] = 0xac183024;
679     Kc[10] = 0x24c07c10;
680     Kc[11] = 0x8c88c038;
681     Kc[12] = 0xc048c824;
682     Kc[13] = 0x4c0470a8;
683     Kc[14] = 0x584020b4;
684     Kc[15] = 0x00742c4c;
685
686     u32 Kd[16];
687
688     Kd[ 0] = 0xa42ce40c;
689     Kd[ 1] = 0x64689858;
690     Kd[ 2] = 0x484050b8;
691     Kd[ 3] = 0xe8184814;
692     Kd[ 4] = 0x405cc070;
693     Kd[ 5] = 0xa010784c;
694     Kd[ 6] = 0x6074a800;
695     Kd[ 7] = 0x80701c1c;
696     Kd[ 8] = 0x9cd49430;
697     Kd[ 9] = 0x4c8ce078;
698     Kd[10] = 0x5c18c088;
699     Kd[11] = 0x28a8a4c8;
700     Kd[12] = 0x3c180838;
701     Kd[13] = 0xb0b86c20;
702     Kd[14] = 0xac84a094;
703     Kd[15] = 0x4ce0c0c4;
704
705     /**
706      * key1 (generate key)
707      */
708
709     u32 iv[2];
710
711     iv[0] = 0;
712     iv[1] = 0;
713
714     for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
715     {
716       u32 data[2];
717
718       data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
719       data[1] = ((dst[k] >>  0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
720
721       data[0] ^= iv[0];
722       data[1] ^= iv[1];
723
724       _des_crypt_encrypt (iv, data, Kc, Kd, s_SPtrans);
725     }
726
727     /**
728      * key2 (generate hash)
729      */
730
731     _des_crypt_keysetup (iv[0], iv[1], Kc, Kd, s_skb);
732
733     iv[0] = 0;
734     iv[1] = 0;
735
736     for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
737     {
738       u32 data[2];
739
740       data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
741       data[1] = ((dst[k] >>  0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
742
743       data[0] ^= iv[0];
744       data[1] ^= iv[1];
745
746       _des_crypt_encrypt (iv, data, Kc, Kd, s_SPtrans);
747     }
748
749     /**
750      * cmp
751      */
752
753     const u32 r0 = iv[0];
754     const u32 r1 = iv[1];
755     const u32 r2 = 0;
756     const u32 r3 = 0;
757
758     #include COMPARE_M
759   }
760 }
761
762 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03100_m08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
763 {
764 }
765
766 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03100_m16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
767 {
768 }
769
770 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03100_s04 (__global pw_t *pws, __global kernel_rule_t *  rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 rules_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
771 {
772   /**
773    * modifier
774    */
775
776   const u32 lid = get_local_id (0);
777
778   /**
779    * base
780    */
781
782   const u32 gid = get_global_id (0);
783
784   u32 pw_buf0[4];
785
786   pw_buf0[0] = pws[gid].i[ 0];
787   pw_buf0[1] = pws[gid].i[ 1];
788   pw_buf0[2] = pws[gid].i[ 2];
789   pw_buf0[3] = pws[gid].i[ 3];
790
791   u32 pw_buf1[4];
792
793   pw_buf1[0] = pws[gid].i[ 4];
794   pw_buf1[1] = pws[gid].i[ 5];
795   pw_buf1[2] = pws[gid].i[ 6];
796   pw_buf1[3] = pws[gid].i[ 7];
797
798   const u32 pw_len = pws[gid].pw_len;
799
800   /**
801    * sbox, kbox
802    */
803
804   __local u32 s_SPtrans[8][64];
805   __local u32 s_skb[8][64];
806
807   s_SPtrans[0][lid] = c_SPtrans[0][lid];
808   s_SPtrans[1][lid] = c_SPtrans[1][lid];
809   s_SPtrans[2][lid] = c_SPtrans[2][lid];
810   s_SPtrans[3][lid] = c_SPtrans[3][lid];
811   s_SPtrans[4][lid] = c_SPtrans[4][lid];
812   s_SPtrans[5][lid] = c_SPtrans[5][lid];
813   s_SPtrans[6][lid] = c_SPtrans[6][lid];
814   s_SPtrans[7][lid] = c_SPtrans[7][lid];
815
816   s_skb[0][lid] = c_skb[0][lid];
817   s_skb[1][lid] = c_skb[1][lid];
818   s_skb[2][lid] = c_skb[2][lid];
819   s_skb[3][lid] = c_skb[3][lid];
820   s_skb[4][lid] = c_skb[4][lid];
821   s_skb[5][lid] = c_skb[5][lid];
822   s_skb[6][lid] = c_skb[6][lid];
823   s_skb[7][lid] = c_skb[7][lid];
824
825   barrier (CLK_LOCAL_MEM_FENCE);
826
827   if (gid >= gid_max) return;
828
829   /**
830    * salt
831    */
832
833   u32 salt_buf0[4];
834
835   salt_buf0[0] = salt_bufs[salt_pos].salt_buf[0];
836   salt_buf0[1] = salt_bufs[salt_pos].salt_buf[1];
837   salt_buf0[2] = salt_bufs[salt_pos].salt_buf[2];
838   salt_buf0[3] = salt_bufs[salt_pos].salt_buf[3];
839
840   u32 salt_buf1[4];
841
842   salt_buf1[0] = salt_bufs[salt_pos].salt_buf[4];
843   salt_buf1[1] = salt_bufs[salt_pos].salt_buf[5];
844   salt_buf1[2] = salt_bufs[salt_pos].salt_buf[6];
845   salt_buf1[3] = salt_bufs[salt_pos].salt_buf[7];
846
847   const u32 salt_len = salt_bufs[salt_pos].salt_len;
848
849   /**
850    * digest
851    */
852
853   const u32 search[4] =
854   {
855     digests_buf[digests_offset].digest_buf[DGST_R0],
856     digests_buf[digests_offset].digest_buf[DGST_R1],
857     digests_buf[digests_offset].digest_buf[DGST_R2],
858     digests_buf[digests_offset].digest_buf[DGST_R3]
859   };
860
861   /**
862    * loop
863    */
864
865   for (u32 il_pos = 0; il_pos < rules_cnt; il_pos++)
866   {
867     u32 w0[4];
868
869     w0[0] = pw_buf0[0];
870     w0[1] = pw_buf0[1];
871     w0[2] = pw_buf0[2];
872     w0[3] = pw_buf0[3];
873
874     u32 w1[4];
875
876     w1[0] = pw_buf1[0];
877     w1[1] = pw_buf1[1];
878     w1[2] = pw_buf1[2];
879     w1[3] = pw_buf1[3];
880
881     u32 w2[4];
882
883     w2[0] = 0;
884     w2[1] = 0;
885     w2[2] = 0;
886     w2[3] = 0;
887
888     u32 w3[4];
889
890     w3[0] = 0;
891     w3[1] = 0;
892     w3[2] = 0;
893     w3[3] = 0;
894
895     const u32 out_len = apply_rules (rules_buf[il_pos].cmds, w0, w1, pw_len);
896
897     const u32 salt_word_len = (salt_len + out_len) * 2;
898
899     /**
900      * prepend salt
901      */
902
903     u32 w0_t[4];
904
905     w0_t[0] = w0[0];
906     w0_t[1] = w0[1];
907     w0_t[2] = w0[2];
908     w0_t[3] = w0[3];
909
910     u32 w1_t[4];
911
912     w1_t[0] = w1[0];
913     w1_t[1] = w1[1];
914     w1_t[2] = w1[2];
915     w1_t[3] = w1[3];
916
917     u32 w2_t[4];
918
919     w2_t[0] = w2[0];
920     w2_t[1] = w2[1];
921     w2_t[2] = w2[2];
922     w2_t[3] = w2[3];
923
924     u32 w3_t[4];
925
926     w3_t[0] = w3[0];
927     w3_t[1] = w3[1];
928     w3_t[2] = w3[2];
929     w3_t[3] = w3[3];
930
931     switch_buffer_by_offset (w0_t, w1_t, w2_t, w3_t, salt_len);
932
933     w0_t[0] |= salt_buf0[0];
934     w0_t[1] |= salt_buf0[1];
935     w0_t[2] |= salt_buf0[2];
936     w0_t[3] |= salt_buf0[3];
937     w1_t[0] |= salt_buf1[0];
938     w1_t[1] |= salt_buf1[1];
939     w1_t[2] |= salt_buf1[2];
940     w1_t[3] |= salt_buf1[3];
941
942     u32 dst[16];
943
944     dst[ 0] = w0_t[0];
945     dst[ 1] = w0_t[1];
946     dst[ 2] = w0_t[2];
947     dst[ 3] = w0_t[3];
948     dst[ 4] = w1_t[0];
949     dst[ 5] = w1_t[1];
950     dst[ 6] = w1_t[2];
951     dst[ 7] = w1_t[3];
952     dst[ 8] = w2_t[0];
953     dst[ 9] = w2_t[1];
954     dst[10] = w2_t[2];
955     dst[11] = w2_t[3];
956     dst[12] = 0;
957     dst[13] = 0;
958     dst[14] = 0;
959     dst[15] = 0;
960
961     /**
962      * precompute key1 since key is static: 0x0123456789abcdef
963      * plus LEFT_ROTATE by 2
964      */
965
966     u32 Kc[16];
967
968     Kc[ 0] = 0x64649040;
969     Kc[ 1] = 0x14909858;
970     Kc[ 2] = 0xc4b44888;
971     Kc[ 3] = 0x9094e438;
972     Kc[ 4] = 0xd8a004f0;
973     Kc[ 5] = 0xa8f02810;
974     Kc[ 6] = 0xc84048d8;
975     Kc[ 7] = 0x68d804a8;
976     Kc[ 8] = 0x0490e40c;
977     Kc[ 9] = 0xac183024;
978     Kc[10] = 0x24c07c10;
979     Kc[11] = 0x8c88c038;
980     Kc[12] = 0xc048c824;
981     Kc[13] = 0x4c0470a8;
982     Kc[14] = 0x584020b4;
983     Kc[15] = 0x00742c4c;
984
985     u32 Kd[16];
986
987     Kd[ 0] = 0xa42ce40c;
988     Kd[ 1] = 0x64689858;
989     Kd[ 2] = 0x484050b8;
990     Kd[ 3] = 0xe8184814;
991     Kd[ 4] = 0x405cc070;
992     Kd[ 5] = 0xa010784c;
993     Kd[ 6] = 0x6074a800;
994     Kd[ 7] = 0x80701c1c;
995     Kd[ 8] = 0x9cd49430;
996     Kd[ 9] = 0x4c8ce078;
997     Kd[10] = 0x5c18c088;
998     Kd[11] = 0x28a8a4c8;
999     Kd[12] = 0x3c180838;
1000     Kd[13] = 0xb0b86c20;
1001     Kd[14] = 0xac84a094;
1002     Kd[15] = 0x4ce0c0c4;
1003
1004     /**
1005      * key1 (generate key)
1006      */
1007
1008     u32 iv[2];
1009
1010     iv[0] = 0;
1011     iv[1] = 0;
1012
1013     for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
1014     {
1015       u32 data[2];
1016
1017       data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
1018       data[1] = ((dst[k] >>  0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
1019
1020       data[0] ^= iv[0];
1021       data[1] ^= iv[1];
1022
1023       _des_crypt_encrypt (iv, data, Kc, Kd, s_SPtrans);
1024     }
1025
1026     /**
1027      * key2 (generate hash)
1028      */
1029
1030     _des_crypt_keysetup (iv[0], iv[1], Kc, Kd, s_skb);
1031
1032     iv[0] = 0;
1033     iv[1] = 0;
1034
1035     for (u32 j = 0, k = 0; j < salt_word_len; j += 8, k++)
1036     {
1037       u32 data[2];
1038
1039       data[0] = ((dst[k] << 16) & 0xff000000) | ((dst[k] << 8) & 0x0000ff00);
1040       data[1] = ((dst[k] >>  0) & 0xff000000) | ((dst[k] >> 8) & 0x0000ff00);
1041
1042       data[0] ^= iv[0];
1043       data[1] ^= iv[1];
1044
1045       _des_crypt_encrypt (iv, data, Kc, Kd, s_SPtrans);
1046     }
1047
1048     /**
1049      * cmp
1050      */
1051
1052     const u32 r0 = iv[0];
1053     const u32 r1 = iv[1];
1054     const u32 r2 = 0;
1055     const u32 r3 = 0;
1056
1057     #include COMPARE_S
1058   }
1059 }
1060
1061 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03100_s08 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
1062 {
1063 }
1064
1065 __kernel void __attribute__((reqd_work_group_size (64, 1, 1))) m03100_s16 (__global pw_t *pws, __global kernel_rule_t *rules_buf, __global comb_t *combs_buf, __global bf_t *bfs_buf, __global void *tmps, __global void *hooks, __global u32 *bitmaps_buf_s1_a, __global u32 *bitmaps_buf_s1_b, __global u32 *bitmaps_buf_s1_c, __global u32 *bitmaps_buf_s1_d, __global u32 *bitmaps_buf_s2_a, __global u32 *bitmaps_buf_s2_b, __global u32 *bitmaps_buf_s2_c, __global u32 *bitmaps_buf_s2_d, __global plain_t *plains_buf, __global digest_t *digests_buf, __global u32 *hashes_shown, __global salt_t *salt_bufs, __global void *esalt_bufs, __global u32 *d_return_buf, __global u32 *d_scryptV_buf, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, const u32 salt_pos, const u32 loop_pos, const u32 loop_cnt, const u32 combs_cnt, const u32 digests_cnt, const u32 digests_offset, const u32 combs_mode, const u32 gid_max)
1066 {
1067 }