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

📄 cciphercontext.h

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

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

#ifndef Included_CCipherContext_h	// [
#define Included_CCipherContext_h

#include "CErrorState.h"
#include "Crypto.h"

_PGP_BEGIN

// Class CCipherContext

class CCipherContext SMART_ERROR_INHERIT
{
public:
	CCipherContext();
	CCipherContext(PGPdiskEncryptionAlgorithm algorithm);
	CCipherContext(const CCipherContext& cipher);
	~CCipherContext();

	CCipherContext&	operator=(const CCipherContext& cipher);
	
	PGPBoolean	IsInitialized() const {return mIsInitialized;}
	PGPBoolean	IsKeyAttached() const {return mIsKeyAttached;}
	PGPdiskEncryptionAlgorithm	Algorithm() const {return mAlgorithm;}

	PGPUInt32	GetEncryptSize() const;
	PGPUInt32	GetDecryptSize() const;
	PGPUInt32	GetKeySize() const;
	PGPUInt32	GetNeededRandomDataSize() const;
	PGPUInt32	GetSizeForExport() const;

	SMART_ERROR	Validate() const;

	SMART_ERROR	Init(PGPdiskEncryptionAlgorithm algorithm);
	SMART_ERROR	Assign(const CCipherContext& cipher);
	void		Cleanup();

	SMART_ERROR	AttachSymmetricKey(const Crypto::SymmetricKey& key, 
		const Crypto::PassphraseSalt& salt);
	SMART_ERROR	GetSymmetricKey(Crypto::SymmetricKey& key) const;
	SMART_ERROR	GetSalt(Crypto::PassphraseSalt& salt) const;

	SMART_ERROR	FlipKeyBytes();

	// numBlocks here refers to blocks of GetEncryptSize() size
	SMART_ERROR	Encrypt(const void *in, void *out, 
		PGPUInt32 numBlocks = 1) const;

	// numBlocks here refers to blocks of GetDecryptSize() size
	SMART_ERROR	Decrypt(const void *in, void *out, 
		PGPUInt32 numBlocks = 1) const;

	// numBlocks here refers to blocks of Crypto::kCipherBlockSize size
	SMART_ERROR	EncryptCFB(PGPUInt64 startBlockIndex, PGPUInt32 numBlocks, 
		const void *inBlocks, void *outBlocks) const;

	// numBlocks here refers to blocks of Crypto::kCipherBlockSize size
	SMART_ERROR	DecryptCFB(PGPUInt64 startBlockIndex, PGPUInt32 numBlocks, 
		const void *inBlocks, void *outBlocks) const;

	SMART_ERROR	EncryptPassphraseKey(const char *passphrase, 
		Crypto::PassphraseKeyInfo& keyInfo) const;
	SMART_ERROR	DecryptPassphraseKey(const char *passphrase, 
		const Crypto::PassphraseSalt& salt, 
		const Crypto::PassphraseKeyInfo &keyInfo);

	// randomData2 need not be 'fresh', but must be same size as randomData1
	SMART_ERROR	GenerateNewSymmetricKey(PGPUInt8 *randomData1, 
		PGPUInt8 *randomData2, PGPUInt32 bytesRandomData, 
		const Crypto::PassphraseSalt& salt);

	SMART_ERROR	Export(void *buffer, PGPUInt32 sizeBuffer) const;
	SMART_ERROR	Import(const void *buffer, PGPUInt32 sizeBuffer);

private:
	PGPBoolean	mIsInitialized;
	PGPBoolean	mIsKeyAttached;

	PGPdiskEncryptionAlgorithm	mAlgorithm;
	Crypto::CipherVTable		mVTable;

	Crypto::KeyHandle	mKeyHandle;
};

_PGP_END

#endif	// ] Included_CCipherContext_h

⌨️ 快捷键说明

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