SourceForge.jp

blowfish.h

説明を見る。
00001 // blowfish.h     interface file for blowfish.cpp
00002 // _THE BLOWFISH ENCRYPTION ALGORITHM_
00003 // by Bruce Schneier
00004 // Revised code--3/20/94
00005 // Converted to C++ class 5/96, Jim Conger
00006 
00007 //ちょっとd金魚が関数の説明や#ifdef条件等を追記しています。
00008 //Bruce Schneier氏、Jim Conger氏に感謝します。
00009 
00010 
00011 #define MAXKEYBYTES     56      // 448 bits max
00012 #define NPASS           16      // SBox passes
00013 
00014 #ifndef DWORD
00015 #define DWORD       unsigned long
00016 #endif
00017 #ifndef WORD
00018 #define WORD        unsigned short
00019 #endif
00020 #ifndef BYTE
00021 #define BYTE        unsigned char
00022 #endif
00023 
00024 
00025 class CBlowFish
00026 {
00027 private:
00028     DWORD       * PArray ;
00029     DWORD       (* SBoxes)[256];
00030     void        Blowfish_encipher (DWORD *xl, DWORD *xr) ;
00031     void        Blowfish_decipher (DWORD *xl, DWORD *xr) ;
00032 
00033 public:
00034             CBlowFish () ;
00035             ~CBlowFish () ;
00040 
00041     void        Initialize (BYTE key[], int keybytes) ;
00043     DWORD       GetOutputLength (DWORD lInputLong) ;
00045     DWORD       Encode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ;
00046     void        Decode (BYTE * pInput, BYTE * pOutput, DWORD lSize) ;
00047 
00048 } ;
00049 
00050 // choose a byte order for your hardware
00051 #define ORDER_DCBA  // chosing Intel in this case
00052 
00053 #ifdef ORDER_DCBA   // DCBA - little endian - intel
00054     union aword {
00055       DWORD dword;
00056       BYTE byte [4];
00057       struct {
00058         unsigned int byte3:8;
00059         unsigned int byte2:8;
00060         unsigned int byte1:8;
00061         unsigned int byte0:8;
00062       } w;
00063     };
00064 #endif
00065 
00066 #ifdef ORDER_ABCD   // ABCD - big endian - motorola
00067     union aword {
00068       DWORD dword;
00069       BYTE byte [4];
00070       struct {
00071         unsigned int byte0:8;
00072         unsigned int byte1:8;
00073         unsigned int byte2:8;
00074         unsigned int byte3:8;
00075       } w;
00076     };
00077 #endif
00078 
00079 #ifdef ORDER_BADC   // BADC - vax
00080     union aword {
00081       DWORD dword;
00082       BYTE byte [4];
00083       struct {
00084         unsigned int byte1:8;
00085         unsigned int byte0:8;
00086         unsigned int byte3:8;
00087         unsigned int byte2:8;
00088       } w;
00089 };
00090 #endif

dkutil 1.02リリース前 d金魚専用マニュアルバージョンに対してSun Dec 28 21:23:07 2003に生成されました。 doxygen 1.3.5