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

📄 default.h

📁 crypt++ 3.2版本
💻 H
字号:
#ifndef CRYPTOPP_DEFAULT_H
#define CRYPTOPP_DEFAULT_H

#include "sha.h"
#include "hmac.h"
#include "des.h"
#include "filters.h"

NAMESPACE_BEGIN(CryptoPP)

typedef DES_EDE2_Encryption Default_ECB_Encryption;
typedef DES_EDE2_Decryption Default_ECB_Decryption;
typedef SHA DefaultHashModule;
typedef HMAC<DefaultHashModule> DefaultMAC;

class DefaultEncryptor : public Filter
{
public:
	DefaultEncryptor(const char *passphrase, BufferedTransformation *outQueue = NULL);

	void Detach(BufferedTransformation *newOut = NULL);
	BufferedTransformation *AttachedTransformation();

	void Put(byte inByte);
	void Put(const byte *inString, unsigned int length);

private:
	member_ptr<Default_ECB_Encryption> m_cipher;
};

class DefaultDecryptor : public FilterWithBufferedInput
{
public:
	DefaultDecryptor(const char *passphrase, BufferedTransformation *outQueue = NULL);

	void Detach(BufferedTransformation *newOut = NULL);
	BufferedTransformation *AttachedTransformation();

	// MAC_GOOD and MAC_BAD are not used in this class but are defined for DefaultDecryptorWithMAC
	enum State {WAITING_FOR_KEYCHECK, KEY_GOOD, KEY_BAD, MAC_GOOD, MAC_BAD};
	State CurrentState() const {return m_state;}

protected:
	void FirstPut(const byte *inString);
	void NextPut(const byte *inString, unsigned int length);
	void LastPut(const byte *inString, unsigned int length);

	State m_state;

private:
	void CheckKey(const byte *salt, const byte *keyCheck);
	SecBlock<char> m_passphrase;
	member_ptr<Default_ECB_Decryption> m_cipher;
};

class DefaultEncryptorWithMAC : public DefaultEncryptor
{
public:
	DefaultEncryptorWithMAC(const char *passphrase, BufferedTransformation *outQueue = NULL);

	void Put(byte inByte);
	void Put(const byte *inString, unsigned int length);
	void InputFinished();

private:
	member_ptr<DefaultMAC> m_mac;
};

class DefaultDecryptorWithMAC : public DefaultDecryptor
{
public:
	DefaultDecryptorWithMAC(const char *passphrase, BufferedTransformation *outQueue = NULL);

	void Detach(BufferedTransformation *newOut = NULL);
	BufferedTransformation *AttachedTransformation();
};

NAMESPACE_END

#endif

⌨️ 快捷键说明

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