Go to the documentation of this file.
59 #ifndef HEADER_BF_LOCL_H
60 #define HEADER_BF_LOCL_H
63 #define c2l(c,l) (l =((unsigned long)(*((c)++))) , \
64 l|=((unsigned long)(*((c)++)))<< 8L, \
65 l|=((unsigned long)(*((c)++)))<<16L, \
66 l|=((unsigned long)(*((c)++)))<<24L)
70 #define c2ln(c,l1,l2,n) { \
74 case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
75 case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
76 case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
77 case 5: l2|=((unsigned long)(*(--(c)))); \
78 case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
79 case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
80 case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
81 case 1: l1|=((unsigned long)(*(--(c)))); \
86 #define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \
87 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
88 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
89 *((c)++)=(unsigned char)(((l)>>24L)&0xff))
93 #define l2cn(l1,l2,c,n) { \
96 case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
97 case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
98 case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
99 case 5: *(--(c))=(unsigned char)(((l2) )&0xff); \
100 case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
101 case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
102 case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
103 case 1: *(--(c))=(unsigned char)(((l1) )&0xff); \
108 #define n2ln(c,l1,l2,n) { \
112 case 8: l2 =((unsigned long)(*(--(c)))) ; \
113 case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
114 case 6: l2|=((unsigned long)(*(--(c))))<<16; \
115 case 5: l2|=((unsigned long)(*(--(c))))<<24; \
116 case 4: l1 =((unsigned long)(*(--(c)))) ; \
117 case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
118 case 2: l1|=((unsigned long)(*(--(c))))<<16; \
119 case 1: l1|=((unsigned long)(*(--(c))))<<24; \
124 #define l2nn(l1,l2,c,n) { \
127 case 8: *(--(c))=(unsigned char)(((l2) )&0xff); \
128 case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
129 case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
130 case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
131 case 4: *(--(c))=(unsigned char)(((l1) )&0xff); \
132 case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
133 case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
134 case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
139 #define n2l(c,l) (l =((unsigned long)(*((c)++)))<<24L, \
140 l|=((unsigned long)(*((c)++)))<<16L, \
141 l|=((unsigned long)(*((c)++)))<< 8L, \
142 l|=((unsigned long)(*((c)++))))
145 #define l2n(l,c) (*((c)++)=(unsigned char)(((l)>>24L)&0xff), \
146 *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
147 *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
148 *((c)++)=(unsigned char)(((l) )&0xff))
163 #define BF_ENC(LL,R,KEY,Pi) (\
165 t= KEY[BF_ROUNDS+2 + 0 + ((R>>24)&0xFF)], \
166 t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \
167 t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \
168 t+= KEY[BF_ROUNDS+2 + 768 + ((R )&0xFF)], \
172 #elif defined(BF_PTR)
175 #define BF_LONG_LOG2 2
177 #define BF_M (0xFF<<BF_LONG_LOG2)
178 #define BF_0 (24-BF_LONG_LOG2)
179 #define BF_1 (16-BF_LONG_LOG2)
180 #define BF_2 ( 8-BF_LONG_LOG2)
181 #define BF_3 BF_LONG_LOG2
192 #define BF_ENC(LL,R,S,P) ( \
194 LL^= (((*(BF_LONG *)((unsigned char *)&(S[ 0])+((R>>BF_0)&BF_M))+ \
195 *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
196 *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
197 *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))) \
209 #define BF_ENC(LL,R,S,P) ( \
211 LL^=((( S[ ((int)(R>>24)&0xff)] + \
212 S[0x0100+((int)(R>>16)&0xff)])^ \
213 S[0x0200+((int)(R>> 8)&0xff)])+ \
214 S[0x0300+((int)(R )&0xff)])&0xffffffffL \