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

📄 crypto.h

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 H
字号:
/*____________________________________________________________________________
		Copyright (C) 2002 PGP Corporation
        All rights reserved.

        $Id: Crypto.h,v 1.5 2002/08/06 20:10:18 dallen Exp $
____________________________________________________________________________*/

#ifndef Included_Crypto_h	// [
#define Included_Crypto_h

#include "pgpDiskPubTypes.h"

_PGP_BEGIN

namespace Crypto
{
	// Constants

	enum {kCipherBlockSize = kPGPdiskBlockSize};

	// Types
	//
	// SymmetricKey stores a symmetric, unexpanded cryptographic key.

	union SymmetricKey
	{
		PGPByte		bytes[128];
		PGPUInt32	dwords[128/sizeof(PGPUInt32)];
	};

	typedef SymmetricKey EncryptedKey;

	// CheckBytes contains 8 bytes of data for passphrase verification.

	struct CheckBytes
	{
		PGPByte	bytes[16];
	};

	// PassphraseSalt contains 8 salt bytes.

	union PassphraseSalt
	{
		PGPByte		bytes[16];
		PGPUInt32	dwords[16/sizeof(PGPUInt32)];
	};

	// PassphraseKeyInfo stores a session key encrypted with a given
	// passphrase. (The salt is stored separately in the main PGPdisk file
	// header.)

	struct PassphraseKeyInfo 
	{
		EncryptedKey	encryptedKey;
		CheckBytes		checkBytes;

		PGPUInt16		hashReps;	// # of hashes on passphrase
		PGPUInt16		reserved1;
		PGPUInt32		reserved2;
	};

	// CipherVTable is the interface for PGPdisk crypto modules.

	typedef void	*KeyHandle;

	struct CipherVTable 
	{
		void (* pfnGetAlgorithmIdString)(
			PGPdiskEncryptionAlgorithm algorithm, char *idString, 
			PGPUInt32 availSize);

		PGPUInt32 (* pfnGetEncryptSize)(KeyHandle keyHandle);
		PGPUInt32 (* pfnGetDecryptSize)(KeyHandle keyHandle);
		PGPUInt32 (* pfnGetKeySize)(KeyHandle keyHandle);
		PGPUInt32 (* pfnGetNeededRandomDataSize)(KeyHandle keyHandle);
		PGPUInt32 (* pfnGetSizeForExport)(KeyHandle keyHandle);

		CComboError (* pfnValidate)(KeyHandle keyHandle);

		CComboError (* pfnInit)(KeyHandle *pKeyHandle, 
			PGPdiskEncryptionAlgorithm algorithm);
		void (* pfnCleanup)(KeyHandle keyHandle);

		CComboError (* pfnAttachSymmetricKey)(KeyHandle keyHandle, 
			const SymmetricKey *pKey, const PassphraseSalt *pSalt);
		CComboError (* pfnGetSymmetricKey)(KeyHandle keyHandle, 
			SymmetricKey *pKey);
		CComboError (* pfnGetSalt)(KeyHandle keyHandle, 
			PassphraseSalt *pSalt);

		CComboError (* pfnFlipKeyBytes)(KeyHandle keyHandle);

		CComboError	(* pfnEncrypt)(KeyHandle keyHandle, const void *in, 
			void *out, PGPUInt32 numBlocks);
		CComboError	(* pfnDecrypt)(KeyHandle keyHandle, const void *in, 
			void *out, PGPUInt32 numBlocks);

		CComboError	(* pfnEncryptCFB)(KeyHandle keyHandle, 
			PGPUInt64 startBlockIndex, PGPUInt32 numBlocks, 
			const void *inBlocks, void *outBlocks);

		CComboError	(* pfnDecryptCFB)(KeyHandle keyHandle, 
			PGPUInt64 startBlockIndex, PGPUInt32 numBlocks, 
			const void *inBlocks, void *outBlocks);

		CComboError	(* pfnEncryptPassphraseKey)(KeyHandle keyHandle, 
			const char *passphrase, PassphraseKeyInfo *pKeyInfo);

		CComboError	(* pfnDecryptPassphraseKey)(KeyHandle keyHandle, 
			const char *passphrase, const PassphraseSalt *pSalt, 
			const PassphraseKeyInfo *pKeyInfo);

		CComboError	(* pfnGenerateNewSymmetricKey)(KeyHandle keyHandle, 
			PGPUInt8 *randomData1, PGPUInt8 *randomData2, 
			PGPUInt32 bytesRandomData, const PassphraseSalt *pSalt);

		CComboError	(* pfnExport)(KeyHandle keyHandle, void *buffer, 
			PGPUInt32 sizeBuffer);
		CComboError	(* pfnImport)(KeyHandle keyHandle, const void *buffer, 
			PGPUInt32 sizeBuffer);
	};
}

_PGP_END

#endif	// Included_Crypto_h

⌨️ 快捷键说明

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