new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / os_crypto / blowfish / bf_locl.h
old mode 100755 (executable)
new mode 100644 (file)
index ea7399e..9c69e8a
@@ -1,9 +1,8 @@
-/* Modified to work without OPENSSL.
+/* Modified to work without OPENSSL
  * os_crypto (www.ossec.net/c/os_crypto)
  * Daniel B. Cid, danielcid@gmail.com
  */
 
-/* crypto/bf/bf_locl.h */
 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
 #define HEADER_BF_LOCL_H
 
 /* Only include if OPENSSL is present */
-#ifdef USE_OPENSSL
+#ifdef LIBOPENSSL_ENABLED
 #include <openssl/opensslconf.h> /* BF_PTR, BF_PTR2 */
 #endif
 
 #undef c2l
-#define c2l(c,l)       (l =((unsigned long)(*((c)++)))    , \
-                        l|=((unsigned long)(*((c)++)))<< 8L, \
-                        l|=((unsigned long)(*((c)++)))<<16L, \
-                        l|=((unsigned long)(*((c)++)))<<24L)
+#define c2l(c,l)    (l =((unsigned long)(*((c)++)))    , \
+             l|=((unsigned long)(*((c)++)))<< 8L, \
+             l|=((unsigned long)(*((c)++)))<<16L, \
+             l|=((unsigned long)(*((c)++)))<<24L)
 
 /* NOTE - c is not incremented as per c2l */
 #undef c2ln
-#define c2ln(c,l1,l2,n)        { \
-                       c+=n; \
-                       l1=l2=0; \
-                       switch (n) { \
-                       case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
-                       case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
-                       case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
-                       case 5: l2|=((unsigned long)(*(--(c))));     \
-                       case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
-                       case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
-                       case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
-                       case 1: l1|=((unsigned long)(*(--(c))));     \
-                               } \
-                       }
+#define c2ln(c,l1,l2,n)    { \
+            c+=n; \
+            l1=l2=0; \
+            switch (n) { \
+            case 8: l2 =((unsigned long)(*(--(c))))<<24L; \
+            case 7: l2|=((unsigned long)(*(--(c))))<<16L; \
+            case 6: l2|=((unsigned long)(*(--(c))))<< 8L; \
+            case 5: l2|=((unsigned long)(*(--(c))));     \
+            case 4: l1 =((unsigned long)(*(--(c))))<<24L; \
+            case 3: l1|=((unsigned long)(*(--(c))))<<16L; \
+            case 2: l1|=((unsigned long)(*(--(c))))<< 8L; \
+            case 1: l1|=((unsigned long)(*(--(c))));     \
+                } \
+            }
 
 #undef l2c
-#define l2c(l,c)       (*((c)++)=(unsigned char)(((l)     )&0xff), \
-                        *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
-                        *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
-                        *((c)++)=(unsigned char)(((l)>>24L)&0xff))
+#define l2c(l,c)    (*((c)++)=(unsigned char)(((l)     )&0xff), \
+             *((c)++)=(unsigned char)(((l)>> 8L)&0xff), \
+             *((c)++)=(unsigned char)(((l)>>16L)&0xff), \
+             *((c)++)=(unsigned char)(((l)>>24L)&0xff))
 
 /* NOTE - c is not incremented as per l2c */
 #undef l2cn
-#define l2cn(l1,l2,c,n)        { \
-                       c+=n; \
-                       switch (n) { \
-                       case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
-                       case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
-                       case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
-                       case 5: *(--(c))=(unsigned char)(((l2)     )&0xff); \
-                       case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
-                       case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
-                       case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
-                       case 1: *(--(c))=(unsigned char)(((l1)     )&0xff); \
-                               } \
-                       }
+#define l2cn(l1,l2,c,n)    { \
+            c+=n; \
+            switch (n) { \
+            case 8: *(--(c))=(unsigned char)(((l2)>>24L)&0xff); \
+            case 7: *(--(c))=(unsigned char)(((l2)>>16L)&0xff); \
+            case 6: *(--(c))=(unsigned char)(((l2)>> 8L)&0xff); \
+            case 5: *(--(c))=(unsigned char)(((l2)     )&0xff); \
+            case 4: *(--(c))=(unsigned char)(((l1)>>24L)&0xff); \
+            case 3: *(--(c))=(unsigned char)(((l1)>>16L)&0xff); \
+            case 2: *(--(c))=(unsigned char)(((l1)>> 8L)&0xff); \
+            case 1: *(--(c))=(unsigned char)(((l1)     )&0xff); \
+                } \
+            }
 
 /* NOTE - c is not incremented as per n2l */
-#define n2ln(c,l1,l2,n)        { \
-                       c+=n; \
-                       l1=l2=0; \
-                       switch (n) { \
-                       case 8: l2 =((unsigned long)(*(--(c))))    ; \
-                       case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
-                       case 6: l2|=((unsigned long)(*(--(c))))<<16; \
-                       case 5: l2|=((unsigned long)(*(--(c))))<<24; \
-                       case 4: l1 =((unsigned long)(*(--(c))))    ; \
-                       case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
-                       case 2: l1|=((unsigned long)(*(--(c))))<<16; \
-                       case 1: l1|=((unsigned long)(*(--(c))))<<24; \
-                               } \
-                       }
+#define n2ln(c,l1,l2,n)    { \
+            c+=n; \
+            l1=l2=0; \
+            switch (n) { \
+            case 8: l2 =((unsigned long)(*(--(c))))    ; \
+            case 7: l2|=((unsigned long)(*(--(c))))<< 8; \
+            case 6: l2|=((unsigned long)(*(--(c))))<<16; \
+            case 5: l2|=((unsigned long)(*(--(c))))<<24; \
+            case 4: l1 =((unsigned long)(*(--(c))))    ; \
+            case 3: l1|=((unsigned long)(*(--(c))))<< 8; \
+            case 2: l1|=((unsigned long)(*(--(c))))<<16; \
+            case 1: l1|=((unsigned long)(*(--(c))))<<24; \
+                } \
+            }
 
 /* NOTE - c is not incremented as per l2n */
-#define l2nn(l1,l2,c,n)        { \
-                       c+=n; \
-                       switch (n) { \
-                       case 8: *(--(c))=(unsigned char)(((l2)    )&0xff); \
-                       case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
-                       case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
-                       case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
-                       case 4: *(--(c))=(unsigned char)(((l1)    )&0xff); \
-                       case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
-                       case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
-                       case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
-                               } \
-                       }
+#define l2nn(l1,l2,c,n)    { \
+            c+=n; \
+            switch (n) { \
+            case 8: *(--(c))=(unsigned char)(((l2)    )&0xff); \
+            case 7: *(--(c))=(unsigned char)(((l2)>> 8)&0xff); \
+            case 6: *(--(c))=(unsigned char)(((l2)>>16)&0xff); \
+            case 5: *(--(c))=(unsigned char)(((l2)>>24)&0xff); \
+            case 4: *(--(c))=(unsigned char)(((l1)    )&0xff); \
+            case 3: *(--(c))=(unsigned char)(((l1)>> 8)&0xff); \
+            case 2: *(--(c))=(unsigned char)(((l1)>>16)&0xff); \
+            case 1: *(--(c))=(unsigned char)(((l1)>>24)&0xff); \
+                } \
+            }
 
 #undef n2l
 #define n2l(c,l)        (l =((unsigned long)(*((c)++)))<<24L, \
  * implementation!
  */
 #define BF_ENC(LL,R,KEY,Pi) (\
-       LL^=KEY[Pi], \
-       t=  KEY[BF_ROUNDS+2 +   0 + ((R>>24)&0xFF)], \
-       t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \
-       t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \
-       t+= KEY[BF_ROUNDS+2 + 768 + ((R    )&0xFF)], \
-       LL^=t \
-       )
+    LL^=KEY[Pi], \
+    t=  KEY[BF_ROUNDS+2 +   0 + ((R>>24)&0xFF)], \
+    t+= KEY[BF_ROUNDS+2 + 256 + ((R>>16)&0xFF)], \
+    t^= KEY[BF_ROUNDS+2 + 512 + ((R>>8 )&0xFF)], \
+    t+= KEY[BF_ROUNDS+2 + 768 + ((R    )&0xFF)], \
+    LL^=t \
+    )
 
 #elif defined(BF_PTR)
 
  */
 
 #define BF_ENC(LL,R,S,P) ( \
-       LL^=P, \
-       LL^= (((*(BF_LONG *)((unsigned char *)&(S[  0])+((R>>BF_0)&BF_M))+ \
-               *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
-               *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
-               *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))) \
-       )
+    LL^=P, \
+    LL^= (((*(BF_LONG *)((unsigned char *)&(S[  0])+((R>>BF_0)&BF_M))+ \
+        *(BF_LONG *)((unsigned char *)&(S[256])+((R>>BF_1)&BF_M)))^ \
+        *(BF_LONG *)((unsigned char *)&(S[512])+((R>>BF_2)&BF_M)))+ \
+        *(BF_LONG *)((unsigned char *)&(S[768])+((R<<BF_3)&BF_M))) \
+    )
 #else
 
 /*
  */
 
 #define BF_ENC(LL,R,S,P) ( \
-       LL^=P, \
-       LL^=((( S[       ((int)(R>>24)&0xff)] + \
-               S[0x0100+((int)(R>>16)&0xff)])^ \
-               S[0x0200+((int)(R>> 8)&0xff)])+ \
-               S[0x0300+((int)(R    )&0xff)])&0xffffffffL \
-       )
+    LL^=P, \
+    LL^=(((    S[       ((int)(R>>24)&0xff)] + \
+        S[0x0100+((int)(R>>16)&0xff)])^ \
+        S[0x0200+((int)(R>> 8)&0xff)])+ \
+        S[0x0300+((int)(R    )&0xff)])&0xffffffffL \
+    )
 #endif
 
 #endif