Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:50:22

0001 /*
0002  * Author     :  Paul Kocher
0003  * E-mail     :  pck@netcom.com
0004  * Date       :  1997
0005  * Description:  C implementation of the Blowfish algorithm.
0006  */
0007 
0008 #define INCLUDE_BLOWFISH_DEFINE_H
0009 
0010 struct BCoptions {
0011   unsigned char remove;
0012   unsigned char standardout;
0013   unsigned char compression;
0014   unsigned char type;
0015   unsigned long origsize;
0016   unsigned char securedelete;
0017 };
0018 
0019 #define ENCRYPT 0
0020 #define DECRYPT 1
0021 
0022 #define endianBig ((unsigned char)0x45)
0023 #define endianLittle ((unsigned char)0x54)
0024 
0025 typedef unsigned int uInt32;
0026 
0027 #ifdef WIN32 /* Win32 doesn't have random() or lstat */
0028 #define random() rand()
0029 #define initstate(x, y, z) srand(x)
0030 #define lstat(x, y) stat(x, y)
0031 #endif
0032 
0033 #ifndef S_ISREG
0034 #define S_ISREG(x) (((x)&S_IFMT) == S_IFREG)
0035 #endif
0036 
0037 #define MAXKEYBYTES 56 /* 448 bits */
0038 
0039 struct BLOWFISH_CTX {
0040   uInt32 P[16 + 2];
0041   uInt32 S[4][256];
0042 };
0043 
0044 void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen);
0045 
0046 void Blowfish_Encrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr);
0047 
0048 void Blowfish_Decrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32 *xr);