CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/CondCore/DBCommon/src/blowfish.h

Go to the documentation of this file.
00001 /*
00002  * Author     :  Paul Kocher
00003  * E-mail     :  pck@netcom.com
00004  * Date       :  1997
00005  * Description:  C implementation of the Blowfish algorithm.
00006  */
00007 
00008 
00009 #define INCLUDE_BLOWFISH_DEFINE_H
00010 
00011 struct BCoptions{
00012   unsigned char remove;
00013   unsigned char standardout;
00014   unsigned char compression;
00015   unsigned char type;
00016   unsigned long origsize;
00017   unsigned char securedelete;
00018 };
00019 
00020 #define ENCRYPT 0
00021 #define DECRYPT 1
00022 
00023 #define endianBig ((unsigned char) 0x45)
00024 #define endianLittle ((unsigned char) 0x54)
00025 
00026 typedef unsigned int uInt32;
00027 
00028 #ifdef WIN32 /* Win32 doesn't have random() or lstat */
00029 #define random() rand()
00030 #define initstate(x,y,z) srand(x)
00031 #define lstat(x,y) stat(x,y)
00032 #endif
00033 
00034 #ifndef S_ISREG
00035 #define S_ISREG(x) ( ((x)&S_IFMT)==S_IFREG )
00036 #endif
00037 
00038 #define MAXKEYBYTES 56          /* 448 bits */
00039 
00040 struct BLOWFISH_CTX {
00041   uInt32 P[16 + 2];
00042   uInt32 S[4][256];
00043 };
00044 
00045 void Blowfish_Init(BLOWFISH_CTX *ctx, unsigned char *key, int keyLen);
00046 
00047 void Blowfish_Encrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32
00048 *xr);
00049 
00050 void Blowfish_Decrypt(BLOWFISH_CTX *ctx, uInt32 *xl, uInt32
00051 *xr);