// CodeGear C++Builder
// Copyright (c) 1995, 2021 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'ABSCipher.pas' rev: 35.00 (Windows)

#ifndef AbscipherHPP
#define AbscipherHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member 
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <ABSDecUtil.hpp>

//-- user supplied -----------------------------------------------------------

namespace Abscipher
{
//-- forward type declarations -----------------------------------------------
class DELPHICLASS ECipherException;
class DELPHICLASS THash;
class DELPHICLASS TCipher;
class DELPHICLASS TCipher_Rijndael;
class DELPHICLASS TCipher_Blowfish;
class DELPHICLASS TCipher_1DES;
class DELPHICLASS TCipher_3DES;
class DELPHICLASS TCipher_3TDES;
class DELPHICLASS TCipher_Twofish;
class DELPHICLASS TCipher_Square;
class DELPHICLASS THash_MD4;
class DELPHICLASS THash_RipeMD128;
class DELPHICLASS THash_RipeMD256;
class DELPHICLASS TChecksum;
//-- type declarations -------------------------------------------------------
class PASCALIMPLEMENTATION ECipherException : public System::Sysutils::Exception
{
	typedef System::Sysutils::Exception inherited;
	
public:
	int ErrorCode;
public:
	/* Exception.Create */ inline __fastcall ECipherException(const System::UnicodeString Msg) : System::Sysutils::Exception(Msg) { }
	/* Exception.CreateFmt */ inline __fastcall ECipherException(const System::UnicodeString Msg, const System::TVarRec *Args, const int Args_High) : System::Sysutils::Exception(Msg, Args, Args_High) { }
	/* Exception.CreateRes */ inline __fastcall ECipherException(NativeUInt Ident)/* overload */ : System::Sysutils::Exception(Ident) { }
	/* Exception.CreateRes */ inline __fastcall ECipherException(System::PResStringRec ResStringRec)/* overload */ : System::Sysutils::Exception(ResStringRec) { }
	/* Exception.CreateResFmt */ inline __fastcall ECipherException(NativeUInt Ident, const System::TVarRec *Args, const int Args_High)/* overload */ : System::Sysutils::Exception(Ident, Args, Args_High) { }
	/* Exception.CreateResFmt */ inline __fastcall ECipherException(System::PResStringRec ResStringRec, const System::TVarRec *Args, const int Args_High)/* overload */ : System::Sysutils::Exception(ResStringRec, Args, Args_High) { }
	/* Exception.CreateHelp */ inline __fastcall ECipherException(const System::UnicodeString Msg, int AHelpContext) : System::Sysutils::Exception(Msg, AHelpContext) { }
	/* Exception.CreateFmtHelp */ inline __fastcall ECipherException(const System::UnicodeString Msg, const System::TVarRec *Args, const int Args_High, int AHelpContext) : System::Sysutils::Exception(Msg, Args, Args_High, AHelpContext) { }
	/* Exception.CreateResHelp */ inline __fastcall ECipherException(NativeUInt Ident, int AHelpContext)/* overload */ : System::Sysutils::Exception(Ident, AHelpContext) { }
	/* Exception.CreateResHelp */ inline __fastcall ECipherException(System::PResStringRec ResStringRec, int AHelpContext)/* overload */ : System::Sysutils::Exception(ResStringRec, AHelpContext) { }
	/* Exception.CreateResFmtHelp */ inline __fastcall ECipherException(System::PResStringRec ResStringRec, const System::TVarRec *Args, const int Args_High, int AHelpContext)/* overload */ : System::Sysutils::Exception(ResStringRec, Args, Args_High, AHelpContext) { }
	/* Exception.CreateResFmtHelp */ inline __fastcall ECipherException(NativeUInt Ident, const System::TVarRec *Args, const int Args_High, int AHelpContext)/* overload */ : System::Sysutils::Exception(Ident, Args, Args_High, AHelpContext) { }
	/* Exception.Destroy */ inline __fastcall virtual ~ECipherException() { }
	
};


enum DECLSPEC_DENUM TCipherMode : unsigned char { cmCTS, cmCBC, cmCFB, cmOFB, cmECB, cmCTSMAC, cmCBCMAC, cmCFBMAC };

_DECLARE_METACLASS(System::TMetaClass, TCipherClass);

class PASCALIMPLEMENTATION THash : public Absdecutil::TProtection
{
	typedef Absdecutil::TProtection inherited;
	
protected:
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall CodeInit(Absdecutil::TPAction Action);
	virtual void __fastcall CodeDone(Absdecutil::TPAction Action);
	virtual void __fastcall CodeBuf(void *Buffer, const int BufferSize, Absdecutil::TPAction Action);
	void __fastcall Protect(bool IsInit);
	
public:
	__fastcall virtual ~THash();
	virtual void __fastcall Init();
	virtual void __fastcall Calc(const void *Data, int DataSize);
	virtual void __fastcall Done();
	virtual void * __fastcall DigestKey();
	System::AnsiString __fastcall DigestStr(int Format);
	__classmethod virtual int __fastcall DigestKeySize();
	__classmethod System::AnsiString __fastcall CalcBuffer(const void *Buffer, int BufferSize, Absdecutil::TProtection* Protection = (Absdecutil::TProtection*)(0x0), int Format = 0xffffffff)/* overload */;
	__classmethod System::AnsiString __fastcall CalcStream(System::Classes::TStream* const Stream, int StreamSize, Absdecutil::TProtection* Protection = (Absdecutil::TProtection*)(0x0), int Format = 0xffffffff)/* overload */;
	__classmethod System::AnsiString __fastcall CalcString(const System::AnsiString Data, Absdecutil::TProtection* Protection = (Absdecutil::TProtection*)(0x0), int Format = 0xffffffff)/* overload */;
	__classmethod System::AnsiString __fastcall CalcFile(const System::UnicodeString FileName, Absdecutil::TProtection* Protection = (Absdecutil::TProtection*)(0x0), int Format = 0xffffffff)/* overload */;
	__classmethod bool __fastcall SelfTest();
public:
	/* TProtection.Create */ inline __fastcall THash(Absdecutil::TProtection* AProtection) : Absdecutil::TProtection(AProtection) { }
	
};


_DECLARE_METACLASS(System::TMetaClass, THashClass);

class PASCALIMPLEMENTATION TCipher : public Absdecutil::TProtection
{
	typedef Absdecutil::TProtection inherited;
	
private:
	TCipherMode FMode;
	THash* FHash;
	THashClass FHashClass;
	int FKeySize;
	int FBufSize;
	int FUserSize;
	void *FBuffer;
	void *FVector;
	void *FFeedback;
	void *FUser;
	int FFlags;
	THash* __fastcall GetHash();
	void __fastcall SetHashClass(THashClass Value);
	
protected:
	bool __fastcall GetFlag(int Index);
	virtual void __fastcall SetFlag(int Index, bool Value);
	void __fastcall InitBegin(int &Size);
	virtual void __fastcall InitEnd(void * IVector);
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall CodeInit(Absdecutil::TPAction Action);
	virtual void __fastcall CodeDone(Absdecutil::TPAction Action);
	virtual void __fastcall CodeBuf(void *Buffer, const int BufferSize, Absdecutil::TPAction Action);
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	__property void * User = {read=FUser};
	__property void * Buffer = {read=FBuffer};
	__property int UserSize = {read=FUserSize, nodefault};
	
public:
	__fastcall TCipher(const System::AnsiString Password, Absdecutil::TProtection* AProtection);
	__fastcall virtual ~TCipher();
	__classmethod int __fastcall MaxKeySize();
	__classmethod bool __fastcall SelfTest();
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
	void __fastcall InitKey(const System::AnsiString Key, void * IVector);
	virtual void __fastcall Done();
	virtual void __fastcall Protect();
	void __fastcall EncodeBuffer(const void *Source, void *Dest, int DataSize);
	void __fastcall DecodeBuffer(const void *Source, void *Dest, int DataSize);
	__property TCipherMode Mode = {read=FMode, write=FMode, nodefault};
	__property THash* Hash = {read=GetHash};
	__property THashClass HashClass = {read=FHashClass, write=SetHashClass};
	__property int KeySize = {read=FKeySize, nodefault};
	__property int BufSize = {read=FBufSize, nodefault};
	__property bool Initialized = {read=GetFlag, write=SetFlag, index=1, nodefault};
	__property void * Vector = {read=FVector};
	__property void * Feedback = {read=FFeedback};
	__property bool HasHashKey = {read=GetFlag, index=0, nodefault};
};


class PASCALIMPLEMENTATION TCipher_Rijndael : public TCipher
{
	typedef TCipher inherited;
	
private:
	int FRounds;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	
public:
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
public:
	/* TCipher.Create */ inline __fastcall TCipher_Rijndael(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_Rijndael() { }
	
};


class PASCALIMPLEMENTATION TCipher_Blowfish : public TCipher
{
	typedef TCipher inherited;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	
public:
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
public:
	/* TCipher.Create */ inline __fastcall TCipher_Blowfish(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_Blowfish() { }
	
};


class PASCALIMPLEMENTATION TCipher_1DES : public TCipher
{
	typedef TCipher inherited;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	void __fastcall MakeKey(const System::Byte *Data, const int Data_High, void * Key_1, bool Reverse);
	
public:
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
public:
	/* TCipher.Create */ inline __fastcall TCipher_1DES(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_1DES() { }
	
};


class PASCALIMPLEMENTATION TCipher_3DES : public TCipher_1DES
{
	typedef TCipher_1DES inherited;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	
public:
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
public:
	/* TCipher.Create */ inline __fastcall TCipher_3DES(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher_1DES(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_3DES() { }
	
};


class PASCALIMPLEMENTATION TCipher_3TDES : public TCipher_3DES
{
	typedef TCipher_3DES inherited;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
public:
	/* TCipher.Create */ inline __fastcall TCipher_3TDES(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher_3DES(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_3TDES() { }
	
};


class PASCALIMPLEMENTATION TCipher_Twofish : public TCipher
{
	typedef TCipher inherited;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	
public:
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
public:
	/* TCipher.Create */ inline __fastcall TCipher_Twofish(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_Twofish() { }
	
};


class PASCALIMPLEMENTATION TCipher_Square : public TCipher
{
	typedef TCipher inherited;
	
protected:
	__classmethod virtual void __fastcall GetContext(int &ABufSize, int &AKeySize, int &AUserSize);
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Encode(void * Data);
	virtual void __fastcall Decode(void * Data);
	
public:
	virtual void __fastcall Init(const void *Key, int Size, void * IVector);
public:
	/* TCipher.Create */ inline __fastcall TCipher_Square(const System::AnsiString Password, Absdecutil::TProtection* AProtection) : TCipher(Password, AProtection) { }
	/* TCipher.Destroy */ inline __fastcall virtual ~TCipher_Square() { }
	
};


class PASCALIMPLEMENTATION THash_MD4 : public THash
{
	typedef THash inherited;
	
private:
	unsigned FCount;
	System::StaticArray<System::Byte, 64> FBuffer;
	System::StaticArray<unsigned, 10> FDigest;
	
protected:
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Transform(Absdecutil::PIntArray Buffer);
	
public:
	__classmethod virtual int __fastcall DigestKeySize();
	virtual void __fastcall Init();
	virtual void __fastcall Done();
	virtual void __fastcall Calc(const void *Data, int DataSize);
	virtual void * __fastcall DigestKey();
public:
	/* THash.Destroy */ inline __fastcall virtual ~THash_MD4() { }
	
public:
	/* TProtection.Create */ inline __fastcall THash_MD4(Absdecutil::TProtection* AProtection) : THash(AProtection) { }
	
};


class PASCALIMPLEMENTATION THash_RipeMD128 : public THash_MD4
{
	typedef THash_MD4 inherited;
	
protected:
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Transform(Absdecutil::PIntArray Buffer);
public:
	/* THash.Destroy */ inline __fastcall virtual ~THash_RipeMD128() { }
	
public:
	/* TProtection.Create */ inline __fastcall THash_RipeMD128(Absdecutil::TProtection* AProtection) : THash_MD4(AProtection) { }
	
};


class PASCALIMPLEMENTATION THash_RipeMD256 : public THash_MD4
{
	typedef THash_MD4 inherited;
	
protected:
	__classmethod virtual void * __fastcall TestVector();
	virtual void __fastcall Transform(Absdecutil::PIntArray Buffer);
	
public:
	__classmethod virtual int __fastcall DigestKeySize();
	virtual void __fastcall Init();
public:
	/* THash.Destroy */ inline __fastcall virtual ~THash_RipeMD256() { }
	
public:
	/* TProtection.Create */ inline __fastcall THash_RipeMD256(Absdecutil::TProtection* AProtection) : THash_MD4(AProtection) { }
	
};


class PASCALIMPLEMENTATION TChecksum : public THash
{
	typedef THash inherited;
	
public:
	/* THash.Destroy */ inline __fastcall virtual ~TChecksum() { }
	
public:
	/* TProtection.Create */ inline __fastcall TChecksum(Absdecutil::TProtection* AProtection) : THash(AProtection) { }
	
};


//-- var, const, procedure ---------------------------------------------------
static const System::Int8 Rijndael_Cipher = System::Int8(0x1);
static const System::Int8 RIPEMD_128_Hash = System::Int8(0x0);
static const System::Int8 RIPEMD_256_Hash = System::Int8(0x1);
static const System::Int8 Default_Cipher_Method = System::Int8(0x1);
static const System::Int8 Default_Hash_Method = System::Int8(0x0);
static const System::Int8 errGeneric = System::Int8(0x0);
static const System::Int8 errInvalidKey = System::Int8(0x1);
static const System::Int8 errInvalidKeySize = System::Int8(0x2);
static const System::Int8 errNotInitialized = System::Int8(0x3);
static const System::Int8 errInvalidMACMode = System::Int8(0x4);
static const System::Int8 errCantCalc = System::Int8(0x5);
extern DELPHI_PACKAGE bool CheckCipherKeySize;
extern DELPHI_PACKAGE TCipherClass __fastcall DefaultCipherClass(void);
extern DELPHI_PACKAGE void __fastcall SetDefaultCipherClass(TCipherClass CipherClass);
extern DELPHI_PACKAGE void __fastcall RaiseCipherException(const int ErrorCode, const System::AnsiString Msg);
extern DELPHI_PACKAGE bool __fastcall RegisterCipher(const TCipherClass ACipher, const System::AnsiString AName, const System::AnsiString ADescription);
extern DELPHI_PACKAGE bool __fastcall UnregisterCipher(const TCipherClass ACipher);
extern DELPHI_PACKAGE System::Classes::TStrings* __fastcall CipherList(void);
extern DELPHI_PACKAGE void __fastcall CipherNames(System::Classes::TStrings* List);
extern DELPHI_PACKAGE TCipherClass __fastcall GetCipherClass(const System::AnsiString Name);
extern DELPHI_PACKAGE System::AnsiString __fastcall GetCipherName(TCipherClass CipherClass);
extern DELPHI_PACKAGE THashClass __fastcall DefaultHashClass(void);
extern DELPHI_PACKAGE void __fastcall SetDefaultHashClass(THashClass HashClass);
extern DELPHI_PACKAGE bool __fastcall RegisterHash(const THashClass AHash, const System::AnsiString AName, const System::AnsiString ADescription);
extern DELPHI_PACKAGE bool __fastcall UnregisterHash(const THashClass AHash);
extern DELPHI_PACKAGE System::Classes::TStrings* __fastcall HashList(void);
extern DELPHI_PACKAGE void __fastcall HashNames(System::Classes::TStrings* List);
extern DELPHI_PACKAGE THashClass __fastcall GetHashClass(const System::AnsiString Name);
extern DELPHI_PACKAGE System::AnsiString __fastcall GetHashName(THashClass HashClass);
}	/* namespace Abscipher */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_ABSCIPHER)
using namespace Abscipher;
#endif
#pragma pack(pop)
#pragma option pop

#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif	// AbscipherHPP
