Go to the documentation of this file.
59 #ifndef HEADER_DES_LOCL_H
60 #define HEADER_DES_LOCL_H
62 #if defined(WIN32) || defined(WIN16)
71 #if defined( INC_ALL )
79 #if defined(__STDC__) || defined(VMS) || defined(M_XENIX) || defined(MSDOS)
84 #define HALF_ITERATIONS 8
87 #define MAXWRITE (1024*16)
94 #define BSIZE (MAXWRITE+4)
97 #define c2l(c,l) (l =((DES_LONG)(*((c)++))) , \
98 l|=((DES_LONG)(*((c)++)))<< 8L, \
99 l|=((DES_LONG)(*((c)++)))<<16L, \
100 l|=((DES_LONG)(*((c)++)))<<24L)
103 #define c2ln(c,l1,l2,n) { \
107 case 8: l2 =((DES_LONG)(*(--(c))))<<24L; \
108 case 7: l2|=((DES_LONG)(*(--(c))))<<16L; \
109 case 6: l2|=((DES_LONG)(*(--(c))))<< 8L; \
110 case 5: l2|=((DES_LONG)(*(--(c)))); \
111 case 4: l1 =((DES_LONG)(*(--(c))))<<24L; \
112 case 3: l1|=((DES_LONG)(*(--(c))))<<16L; \
113 case 2: l1|=((DES_LONG)(*(--(c))))<< 8L; \
114 case 1: l1|=((DES_LONG)(*(--(c)))); \
118 #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
119 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
120 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
121 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
127 #define n2l(c,l) (l =((DES_LONG)(*((c)++)))<<24L, \
128 l|=((DES_LONG)(*((c)++)))<<16L, \
129 l|=((DES_LONG)(*((c)++)))<< 8L, \
130 l|=((DES_LONG)(*((c)++))))
132 #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
133 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
134 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
135 *((c)++)=(unsigned char)(((l) )&0xff))
138 #define l2cn(l1,l2,c,n) { \
141 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
142 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
143 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
144 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
145 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
146 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
147 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
148 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
152 #if defined(WIN32) && defined(_MSC_VER)
153 #define ROTATE(a,n) (_lrotr(a,n))
155 #define ROTATE(a,n) (((a)>>(n))+((a)<<(32-(n))))
163 #define LOAD_DATA_tmp(R,S,u,t,E0,E1) \
164 { DES_LONG tmp; LOAD_DATA(R,S,u,t,E0,E1,tmp); }
166 #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
169 tmp=(u<<16); u^=R^s[S ]; u^=tmp; \
170 tmp=(t<<16); t^=R^s[S+1]; t^=tmp
172 #define LOAD_DATA_tmp(a,b,c,d,e,f) LOAD_DATA(a,b,c,d,e,f,g)
173 #define LOAD_DATA(R,S,u,t,E0,E1,tmp) \
190 #if defined(DES_RISC1) || defined(DES_RISC2)
192 #define D_ENCRYPT(LL,R,S) { \
193 unsigned int u1,u2,u3; \
194 LOAD_DATA(R,S,u,t,E0,E1,u1); \
200 LL^= *(const DES_LONG *)(des_SP +u1); \
201 LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
205 LL^= *(const DES_LONG *)(des_SP+0x400+u1); \
206 LL^= *(const DES_LONG *)(des_SP+0x600+u3); \
211 LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
212 LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
216 LL^= *(const DES_LONG *)(des_SP+0x500+u1); \
217 LL^= *(const DES_LONG *)(des_SP+0x700+u3); }
220 #define D_ENCRYPT(LL,R,S) { \
221 unsigned int u1,u2,s1,s2; \
222 LOAD_DATA(R,S,u,t,E0,E1,u1); \
227 LL^= *(const DES_LONG *)(des_SP +u1); \
228 LL^= *(const DES_LONG *)(des_SP+0x200+u2); \
233 LL^= *(const DES_LONG *)(des_SP+0x400+s1); \
234 LL^= *(const DES_LONG *)(des_SP+0x600+s2); \
238 LL^= *(const DES_LONG *)(des_SP+0x100+u1); \
239 LL^= *(const DES_LONG *)(des_SP+0x300+u2); \
244 LL^= *(const DES_LONG *)(des_SP+0x500+s1); \
245 LL^= *(const DES_LONG *)(des_SP+0x700+s2); }
248 #define D_ENCRYPT(LL,R,S) { \
249 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
252 *(const DES_LONG *)(des_SP +((u )&0xfc))^ \
253 *(const DES_LONG *)(des_SP+0x200+((u>> 8L)&0xfc))^ \
254 *(const DES_LONG *)(des_SP+0x400+((u>>16L)&0xfc))^ \
255 *(const DES_LONG *)(des_SP+0x600+((u>>24L)&0xfc))^ \
256 *(const DES_LONG *)(des_SP+0x100+((t )&0xfc))^ \
257 *(const DES_LONG *)(des_SP+0x300+((t>> 8L)&0xfc))^ \
258 *(const DES_LONG *)(des_SP+0x500+((t>>16L)&0xfc))^ \
259 *(const DES_LONG *)(des_SP+0x700+((t>>24L)&0xfc)); }
264 #if defined(DES_RISC1) || defined(DES_RISC2)
266 #define D_ENCRYPT(LL,R,S) {\
267 unsigned int u1,u2,u3; \
268 LOAD_DATA(R,S,u,t,E0,E1,u1); \
275 LL^=des_SPtrans[0][u1]; \
276 LL^=des_SPtrans[2][u2]; \
280 LL^=des_SPtrans[4][u1]; \
281 LL^=des_SPtrans[6][u3]; \
286 LL^=des_SPtrans[1][u1]; \
287 LL^=des_SPtrans[3][u2]; \
291 LL^=des_SPtrans[5][u1]; \
292 LL^=des_SPtrans[7][u3]; }
295 #define D_ENCRYPT(LL,R,S) {\
296 unsigned int u1,u2,s1,s2; \
297 LOAD_DATA(R,S,u,t,E0,E1,u1); \
303 LL^=des_SPtrans[0][u1]; \
304 LL^=des_SPtrans[2][u2]; \
309 LL^=des_SPtrans[4][s1]; \
310 LL^=des_SPtrans[6][s2]; \
314 LL^=des_SPtrans[1][u1]; \
315 LL^=des_SPtrans[3][u2]; \
320 LL^=des_SPtrans[5][s1]; \
321 LL^=des_SPtrans[7][s2]; }
326 #define D_ENCRYPT(LL,R,S) {\
327 LOAD_DATA_tmp(R,S,u,t,E0,E1); \
330 des_SPtrans[0][(u>> 2L)&0x3f]^ \
331 des_SPtrans[2][(u>>10L)&0x3f]^ \
332 des_SPtrans[4][(u>>18L)&0x3f]^ \
333 des_SPtrans[6][(u>>26L)&0x3f]^ \
334 des_SPtrans[1][(t>> 2L)&0x3f]^ \
335 des_SPtrans[3][(t>>10L)&0x3f]^ \
336 des_SPtrans[5][(t>>18L)&0x3f]^ \
337 des_SPtrans[7][(t>>26L)&0x3f]; }
378 #define PERM_OP(a,b,t,n,m) ((t)=((((a)>>(n))^(b))&(m)),\
384 register DES_LONG tt; \
385 PERM_OP(r,l,tt, 4,0x0f0f0f0fL); \
386 PERM_OP(l,r,tt,16,0x0000ffffL); \
387 PERM_OP(r,l,tt, 2,0x33333333L); \
388 PERM_OP(l,r,tt, 8,0x00ff00ffL); \
389 PERM_OP(r,l,tt, 1,0x55555555L); \
394 register DES_LONG tt; \
395 PERM_OP(l,r,tt, 1,0x55555555L); \
396 PERM_OP(r,l,tt, 8,0x00ff00ffL); \
397 PERM_OP(l,r,tt, 2,0x33333333L); \
398 PERM_OP(r,l,tt,16,0x0000ffffL); \
399 PERM_OP(l,r,tt, 4,0x0f0f0f0fL); \