⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interface of warpdll.txt

📁 应用编码与计算机密码学>程序 如果好的话请发言
💻 TXT
字号:
//For version 5.2
//update: 2003.3.2

//**********************************************************************************************
//General:
//
//LKey and RKey contain 28 bits legal key each. The uper 4 bits are useless.
//LExKey contains 16bit exchange flag.
//RExKey contains 32bit XOR data.
//
//If you use ThreadEncrytp/ThreadDecrypt to encrypt/decrypt files, the DLL create a different
//thread to do these with every call to these functions. The number of calls is unlimited. 
//
//But if you want to control the detail in encryption/decryption, you must use other functions.
//The general steps are following: 
//Generate a S_Box (Gen_S_Box).
//Initial the S_Box with the S_Box_Indentifer (Init_S_Box).
//Initial the Subkey going with the S_Box (Init_ENC_Subkeys or Init_DEC_Subkeys).
//Encrypt/decrypt your data with proper codes.
//Reset the S_Box for safety (Reset_S_Box).
//Drop the Subkey for safety (Drop_Subkeys)
//Drop the S_Box and recycle the space (Drop_S_Box).
//**********************************************************************************************



#define PROGRESS_ALL_FINISHED 101	//Indicate the encrypt/decrypt thread has finished.
#define PROGRESS_WRITING_FINISHED 100	//Indicate the write file progress has finished.

enum WarpStatues
{
	S_ALL_RIGHT=0,
	S_VERSION_NOT_MATCH,
	S_FILE_OPEN_ERROR,
	S_FILE_NAME_EMPTY,
	S_FILE_CORRUPTED,
	S_KEY_INCURRECT,
	S_WEAK_KEY,
	S_CANCELED
};

//Structed paraments to transport to function Encrypt/Decrypt
typedef struct
{
	char* lpszFilename;
	char* lpszKeys;       	//27 bytes in maximum.
	bool bHalt;	            //If bHalt==true, thread ends.
	int iCompleteProgress;	//What progress thread finishs. 
							//When this integer reachs 100, 
							//the thread SHOULD NOT be canceled because of file renaming. 
							//This integer all ways become 101 when the thread aborts.
	WarpStatues statue;		//Why the thread aborts.
}
WARPARAMS,*PWARPARAMS

//Get this DLL's version.

EXPORT unsigned long CALLBACK Version();


//Encrypt a file by a new thread. Return value is the same to _beginthread().

EXPORT long CALLBACK ThreadEncrypt(PWARPARAMS pparams);


//Decrypt a file by a new thread. Return value is the same to _beginthread().

EXPORT long CALLBACK ThreadDecrypt(PWARPARAMS pparams);


//Encrypt a file without creating a new thread.

EXPORT void CALLBACK Encrypt(PWARPARAMS pparams);


//Decrypt a file without creating a new thread.

EXPORT void CALLBACK Decrypt(PWARPARAMS pparams);


//Encrypt a 64-bit data. The 64-bit data must store in two DWORDs.

EXPORT void CALLBACK DES_ENC(DWORD* LData, DWORD* RData, DWORD* LKey, DWORD* RKey, 
							 unsigned long S_Box_Indentifer);


//DEcrypt a 64-bit data. The 64-bit data must store in two DWORDs.

EXPORT void CALLBACK DES_DEC(DWORD* LData, DWORD* RData, DWORD* LKey, DWORD* RKey,
							 unsigned long S_Box_Indentifer);


//Check whether the 64-bit key is a weak key.The 64-bit key must store in two DWORDs.
//Return -1 if the 64-bit key is a weak key.

EXPORT long CALLBACK IsWeakKey(DWORD* LKey,DWORD* RKey);


//Generate a S_Box. Return the indentifer of the S_Box. Return -1 if failed.

EXPORTDLL unsigned long CALLBACK Gen_S_Box();


//Initial the key-relative S_Box.

EXPORT void CALLBACK Init_S_Box(DWORD* LExKey, DWORD* RExKey, unsigned long S_Box_Indentifer);


//Reset a specified S_Box to to origin S_Box.

EXPORT void CALLBACK Reset_S_Box(unsigned long S_Box_Indentifer);


//Drop a specified S_Box and recycle the space.

EXPORTDLL void CALLBACK Drop_S_Box(unsigned long S_Box_Indentifer);


//These four functions are used in case you have many data to encrypt with the
//same key.
//Generate and store the 16 subkeys used in each DES encrytion.

EXPORTDLL void CALLBACK Init_ENC_Subkeys(DWORD* LKey,
										 DWORD* RKey,
										 unsigned long S_Box_Indentifer);


//Generate and store the 16 subkeys used in each DES decryption.

EXPORTDLL void CALLBACK Init_DEC_Subkeys(DWORD* LKey,
										 DWORD* RKey,
										 unsigned long S_Box_Indentifer);

//Reset a specified Subkey to 0.

EXPORTDLL void CALLBACK Reset_Subkeys(unsigned long S_Box_Indentifer);


//Encrypt the 64-bit data with rebuilded S_Box. Compressed_ENC_Key 
//contains 16 compressed 48-bit sub_keys generated by functon Init_ENC_Cmpkeys().

EXPORTDLL void CALLBACK Fast_ENC(DWORD* LData,DWORD* RData,
								 unsigned long S_Box_Indentifer);


//Decrypt the 64-bit data with rebuilded S_Box. Compressed_DEC_Key 
//contains 16 compressed 48-bit sub_keys generated by functon Init_ENC_Cmpkeys().

EXPORTDLL long CALLBACK Fast_DEC(DWORD* LData,DWORD* RData,
								 unsigned long S_Box_Indentifer);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -