home *** CD-ROM | disk | FTP | other *** search
- // Borland C++ Builder
- // Copyright (c) 1995, 1998 by Borland International
- // All rights reserved
-
- // (DO NOT EDIT: machine generated header) 'Blowfish.pas' rev: 3.00
-
- #ifndef BlowfishHPP
- #define BlowfishHPP
- #include <Classes.hpp>
- #include <SysInit.hpp>
- #include <System.hpp>
-
- //-- user supplied -----------------------------------------------------------
-
- namespace Blowfish
- {
- //-- type declarations -------------------------------------------------------
- #pragma pack(push, 1)
- struct SingleBytes
- {
- Byte byte3;
- Byte byte2;
- Byte byte1;
- Byte byte0;
- } ;
- #pragma pack(pop)
-
- #pragma pack(push, 1)
- struct DoublWord
- {
-
- union
- {
- Byte fByte[4];
- SingleBytes w;
- int LWord;
-
- };
- } ;
- #pragma pack(pop)
-
- typedef DoublWord *PDoublWord;
-
- typedef Byte TBlock[8];
-
- typedef TBlock *PBlock;
-
- typedef int PArray[18];
-
- typedef int SArray[4][256];
-
- #pragma pack(push, 1)
- struct Tblf_ctx
- {
- bool Initialised;
- bool IVInitialised;
- Byte IV[8];
- Byte ct[8];
- int S[4][256];
- int P[18];
- union
- {
- int LongBuffer[2];
- Byte ByteBuffer[8];
-
- };
- } ;
- #pragma pack(pop)
-
- enum TCipherMode { ECB, CBC, CFB, OFB };
-
- enum TStringMode { smEncode, smNormal };
-
- class DELPHICLASS TBlowfish;
- class PASCALIMPLEMENTATION TBlowfish : public Classes::TComponent
- {
- typedef Classes::TComponent inherited;
-
- private:
- Tblf_ctx ctx;
- DoublWord *FPtrL;
- DoublWord *FPtrR;
- Byte FBuffer[4105];
- TBlock *PtrBuffer;
- TCipherMode FCipherMode;
- TStringMode FStringMode;
- void __fastcall NagRegister(void);
- void __fastcall InitialiseCore(const System::AnsiString key, int keybytes);
- void __fastcall Core_Encipher(void);
- void __fastcall Core_Decipher(void);
- int __fastcall EncryptBuffer(int &Len);
- int __fastcall DecryptBuffer(int &Len);
- void __fastcall EncryptBlockMode(void);
- void __fastcall DecryptBlockMode(void);
- void __fastcall DoRound(DoublWord &a, DoublWord &b, Byte n);
- void __fastcall InitArray(void);
- void __fastcall EncBlock(void);
- void __fastcall DecBlock(void);
- System::AnsiString __fastcall EncodeString(System::AnsiString InputString);
- System::AnsiString __fastcall DecodeString(System::AnsiString InputString);
-
- public:
- int __fastcall InitialiseString(const System::AnsiString Key);
- int __fastcall InitialiseByte(const Byte * Key, const int Key_Size, int keylength);
- void __fastcall LoadIVString(const System::AnsiString IVString);
- void __fastcall LoadIVByte(const Byte * IVByte, const int IVByte_Size, int IVLength);
- int __fastcall EncryptString(const System::AnsiString Input, System::AnsiString &Output);
- int __fastcall DecryptString(const System::AnsiString Input, System::AnsiString &Output);
- int __fastcall EncryptBlock(const Byte * Input, Byte * Output);
- int __fastcall DecryptBlock(const Byte * Input, Byte * Output);
- int __fastcall EncryptFile(const System::AnsiString InputFileName, System::AnsiString OutputFileName
- );
- int __fastcall DecryptFile(const System::AnsiString InputFileName, System::AnsiString OutputFileName
- );
- int __fastcall CBCMACBlock(Byte * MAC);
- int __fastcall CBCMACString(System::AnsiString &MAC);
- void __fastcall Burn(void);
- System::AnsiString __fastcall GetVersion(void);
-
- __published:
- __property TCipherMode CipherMode = {read=FCipherMode, write=FCipherMode, nodefault};
- __property TStringMode StringMode = {read=FStringMode, write=FStringMode, nodefault};
- public:
- /* TComponent.Create */ __fastcall virtual TBlowfish(Classes::TComponent* AOwner) : Classes::TComponent(
- AOwner) { }
- /* TComponent.Destroy */ __fastcall virtual ~TBlowfish(void) { }
-
- };
-
- //-- var, const, procedure ---------------------------------------------------
- #define OK (Byte)(0)
- #define KEY_NOT_SET (Shortint)(-1)
- #define ZERO_KEY_LENGTH (Shortint)(-2)
- #define MSG_TOO_SHORT (Shortint)(-3)
- #define IV_NOT_SET (Shortint)(-4)
- #define FILE_ERROR (Shortint)(-5)
- #define MODE_NOT_CBC (Shortint)(-6)
- #define BLOCKSIZE (Byte)(8)
- #define BUFFERLENGTH (Word)(4096)
- extern PACKAGE void __fastcall Register(void);
-
- } /* namespace Blowfish */
- #if !defined(NO_IMPLICIT_NAMESPACE_USE)
- using namespace Blowfish;
- #endif
- //-- end unit ----------------------------------------------------------------
- #endif // Blowfish
-