75 #ifdef POK_NEEDS_PROTOCOLS_BLOWFISH
79 #ifndef HEADER_BF_LOCL_H
80 #define HEADER_BF_LOCL_H
83 #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
84 l|=((unsigned long)(*((c)++)))<< 8L, \
85 l|=((unsigned long)(*((c)++)))<<16L, \
86 l|=((unsigned long)(*((c)++)))<<24L)
90 #define c2ln(c,l1,l2,n) { \
94 case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
95 case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
96 case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
97 case 5: l2|=((unsigned long)(*(--(c)))); \
98 case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
99 case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
100 case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
101 case 1: l1|=((unsigned long)(*(--(c)))); \
106 #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
107 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
108 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
109 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
113 #define l2cn(l1,l2,c,n) { \
116 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
117 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
118 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
119 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
120 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
121 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
122 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
123 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
128 #define n2ln(c,l1,l2,n) { \
132 case 8: l2 =((unsigned long)(*(--(c)))) ; \
133 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
134 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
135 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
136 case 4: l1 =((unsigned long)(*(--(c)))) ; \
137 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
138 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
139 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
144 #define l2nn(l1,l2,c,n) { \
147 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
148 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
149 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
150 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
151 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
152 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
153 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
154 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
159 #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
160 l|=((unsigned long)(*((c)++)))<<16L, \
161 l|=((unsigned long)(*((c)++)))<< 8L, \
162 l|=((unsigned long)(*((c)++))))
165 #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
166 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
167 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
168 *((c)++)=(unsigned char)(((l) )&0xff))
183 #define BF_ENC(LL,R,KEY,Pi) (\
185 t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \
186 t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \
187 t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \
188 t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \
192 #elif defined(BF_PTR)
195 #define BF_LONG_LOG2 2
197 #define BF_M (0xFF<<BF_LONG_LOG2)
198 #define BF_0 (24-BF_LONG_LOG2)
199 #define BF_1 (16-BF_LONG_LOG2)
200 #define BF_2 ( 8-BF_LONG_LOG2)
201 #define BF_3 BF_LONG_LOG2
212 #define BF_ENC(LL,R,S,P) ( \
214 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
215 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
216 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
217 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))) \
229 #define BF_ENC(LL,R,S,P) ( \
231 LL^=((( S[ ((int)(R>>24)&0xff)] + \
232 S[0x0100+((int)(R>>16)&0xff)])^ \
233 S[0x0200+((int)(R>> 8)&0xff)])+ \
234 S[0x0300+((int)(R )&0xff)])&0xffffffffL \