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

📄 filters.h

📁 lots Elliptic curve cryptography codes. Use Visual c++ to compile
💻 H
📖 第 1 页 / 共 3 页
字号:
	void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);	void FirstPut(const byte *inString);	void NextPutMultiple(const byte *inString, size_t length);	void NextPutModifiable(byte *inString, size_t length);	void LastPut(const byte *inString, size_t length);	static size_t LastBlockSize(StreamTransformation &c, BlockPaddingScheme padding);	StreamTransformation &m_cipher;	BlockPaddingScheme m_padding;	unsigned int m_optimalBufferSize;};#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITYtypedef StreamTransformationFilter StreamCipherFilter;#endif//! Filter Wrapper for HashTransformationclass CRYPTOPP_DLL HashFilter : public Bufferless<Filter>, private FilterPutSpaceHelper{public:	HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL);	std::string AlgorithmName() const {return m_hashModule.AlgorithmName();}	void IsolatedInitialize(const NameValuePairs &parameters);	size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);	byte * CreatePutSpace(size_t &size) {return m_hashModule.CreateUpdateSpace(size);}private:	HashTransformation &m_hashModule;	bool m_putMessage;	unsigned int m_digestSize;	byte *m_space;	std::string m_messagePutChannel, m_hashPutChannel;};//! Filter Wrapper for HashTransformationclass CRYPTOPP_DLL HashVerificationFilter : public FilterWithBufferedInput{public:	class HashVerificationFailed : public Exception	{	public:		HashVerificationFailed()			: Exception(DATA_INTEGRITY_CHECK_FAILED, "HashVerificationFilter: message hash or MAC not valid") {}	};	enum Flags {HASH_AT_END=0, HASH_AT_BEGIN=1, PUT_MESSAGE=2, PUT_HASH=4, PUT_RESULT=8, THROW_EXCEPTION=16, DEFAULT_FLAGS = HASH_AT_BEGIN | PUT_RESULT};	HashVerificationFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1);	std::string AlgorithmName() const {return m_hashModule.AlgorithmName();}	bool GetLastResult() const {return m_verified;}protected:	void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);	void FirstPut(const byte *inString);	void NextPutMultiple(const byte *inString, size_t length);	void LastPut(const byte *inString, size_t length);private:	friend class AuthenticatedDecryptionFilter;	HashTransformation &m_hashModule;	word32 m_flags;	unsigned int m_digestSize;	bool m_verified;	SecByteBlock m_expectedHash;};typedef HashVerificationFilter HashVerifier;	// for backwards compatibility//! Filter wrapper for encrypting with AuthenticatedSymmetricCipher, optionally handling padding/unpadding when needed/*! Additional authenticated data should be given in channel "AAD". If putAAD is true, AAD will be Put() to the attached BufferedTransformation in channel "AAD". */class CRYPTOPP_DLL AuthenticatedEncryptionFilter : public StreamTransformationFilter{public:	/*! See StreamTransformationFilter for documentation on BlockPaddingScheme  */	AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding = DEFAULT_PADDING);	void IsolatedInitialize(const NameValuePairs &parameters);	byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);	size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking);	void LastPut(const byte *inString, size_t length);protected:	HashFilter m_hf;};//! Filter wrapper for decrypting with AuthenticatedSymmetricCipher, optionally handling padding/unpadding when needed/*! Additional authenticated data should be given in channel "AAD". */class CRYPTOPP_DLL AuthenticatedDecryptionFilter : public FilterWithBufferedInput, public BlockPaddingSchemeDef{public:	enum Flags {MAC_AT_END=0, MAC_AT_BEGIN=1, THROW_EXCEPTION=16, DEFAULT_FLAGS = THROW_EXCEPTION};	/*! See StreamTransformationFilter for documentation on BlockPaddingScheme  */	AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding = DEFAULT_PADDING);	std::string AlgorithmName() const {return m_hashVerifier.AlgorithmName();}	byte * ChannelCreatePutSpace(const std::string &channel, size_t &size);	size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking);	bool GetLastResult() const {return m_hashVerifier.GetLastResult();}protected:	void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);	void FirstPut(const byte *inString);	void NextPutMultiple(const byte *inString, size_t length);	void LastPut(const byte *inString, size_t length);	HashVerificationFilter m_hashVerifier;	StreamTransformationFilter m_streamFilter;};//! Filter Wrapper for PK_Signerclass CRYPTOPP_DLL SignerFilter : public Unflushable<Filter>{public:	SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false)		: m_rng(rng), m_signer(signer), m_messageAccumulator(signer.NewSignatureAccumulator(rng)), m_putMessage(putMessage) {Detach(attachment);}	std::string AlgorithmName() const {return m_signer.AlgorithmName();}	void IsolatedInitialize(const NameValuePairs &parameters);	size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking);private:	RandomNumberGenerator &m_rng;	const PK_Signer &m_signer;	member_ptr<PK_MessageAccumulator> m_messageAccumulator;	bool m_putMessage;	SecByteBlock m_buf;};//! Filter Wrapper for PK_Verifierclass CRYPTOPP_DLL SignatureVerificationFilter : public FilterWithBufferedInput{public:	class SignatureVerificationFailed : public Exception	{	public:		SignatureVerificationFailed()			: Exception(DATA_INTEGRITY_CHECK_FAILED, "VerifierFilter: digital signature not valid") {}	};	enum Flags {SIGNATURE_AT_END=0, SIGNATURE_AT_BEGIN=1, PUT_MESSAGE=2, PUT_SIGNATURE=4, PUT_RESULT=8, THROW_EXCEPTION=16, DEFAULT_FLAGS = SIGNATURE_AT_BEGIN | PUT_RESULT};	SignatureVerificationFilter(const PK_Verifier &verifier, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS);	std::string AlgorithmName() const {return m_verifier.AlgorithmName();}	bool GetLastResult() const {return m_verified;}protected:	void InitializeDerivedAndReturnNewSizes(const NameValuePairs &parameters, size_t &firstSize, size_t &blockSize, size_t &lastSize);	void FirstPut(const byte *inString);	void NextPutMultiple(const byte *inString, size_t length);	void LastPut(const byte *inString, size_t length);private:	const PK_Verifier &m_verifier;	member_ptr<PK_MessageAccumulator> m_messageAccumulator;	word32 m_flags;	SecByteBlock m_signature;	bool m_verified;};typedef SignatureVerificationFilter VerifierFilter;	// for backwards compatibility//! Redirect input to another BufferedTransformation without owning itclass CRYPTOPP_DLL Redirector : public CustomSignalPropagation<Sink>{public:	enum Behavior	{		DATA_ONLY = 0x00,		PASS_SIGNALS = 0x01,		PASS_WAIT_OBJECTS = 0x02,		PASS_EVERYTHING = PASS_SIGNALS | PASS_WAIT_OBJECTS	};	Redirector() : m_target(NULL), m_behavior(PASS_EVERYTHING) {}	Redirector(BufferedTransformation &target, Behavior behavior=PASS_EVERYTHING)		: m_target(&target), m_behavior(behavior) {}	void Redirect(BufferedTransformation &target) {m_target = &target;}	void StopRedirection() {m_target = NULL;}	Behavior GetBehavior() {return (Behavior) m_behavior;}	void SetBehavior(Behavior behavior) {m_behavior=behavior;}	bool GetPassSignals() const {return (m_behavior & PASS_SIGNALS) != 0;}	void SetPassSignals(bool pass) { if (pass) m_behavior |= PASS_SIGNALS; else m_behavior &= ~(word32) PASS_SIGNALS; }	bool GetPassWaitObjects() const {return (m_behavior & PASS_WAIT_OBJECTS) != 0;}	void SetPassWaitObjects(bool pass) { if (pass) m_behavior |= PASS_WAIT_OBJECTS; else m_behavior &= ~(word32) PASS_WAIT_OBJECTS; }	bool CanModifyInput() const		{return m_target ? m_target->CanModifyInput() : false;}	void Initialize(const NameValuePairs &parameters, int propagation);	byte * CreatePutSpace(size_t &size)		{return m_target ? m_target->CreatePutSpace(size) : (byte *)(size=0, NULL);}	size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking)		{return m_target ? m_target->Put2(begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;}	bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)		{return m_target && GetPassSignals() ? m_target->Flush(hardFlush, propagation, blocking) : false;}	bool MessageSeriesEnd(int propagation=-1, bool blocking=true)		{return m_target && GetPassSignals() ? m_target->MessageSeriesEnd(propagation, blocking) : false;}	byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)		{return m_target ? m_target->ChannelCreatePutSpace(channel, size) : (byte *)(size=0, NULL);}	size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)		{return m_target ? m_target->ChannelPut2(channel, begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;}	size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)		{return m_target ? m_target->ChannelPutModifiable2(channel, begin, length, GetPassSignals() ? messageEnd : 0, blocking) : 0;}	bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)		{return m_target && GetPassSignals() ? m_target->ChannelFlush(channel, completeFlush, propagation, blocking) : false;}	bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true)		{return m_target && GetPassSignals() ? m_target->ChannelMessageSeriesEnd(channel, propagation, blocking) : false;}	unsigned int GetMaxWaitObjectCount() const		{ return m_target && GetPassWaitObjects() ? m_target->GetMaxWaitObjectCount() : 0; }	void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack)		{ if (m_target && GetPassWaitObjects()) m_target->GetWaitObjects(container, callStack); }private:	BufferedTransformation *m_target;	word32 m_behavior;};// Used By ProxyFilterclass CRYPTOPP_DLL OutputProxy : public CustomSignalPropagation<Sink>{public:	OutputProxy(BufferedTransformation &owner, bool passSignal) : m_owner(owner), m_passSignal(passSignal) {}	bool GetPassSignal() const {return m_passSignal;}	void SetPassSignal(bool passSignal) {m_passSignal = passSignal;}	byte * CreatePutSpace(size_t &size)		{return m_owner.AttachedTransformation()->CreatePutSpace(size);}	size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking)		{return m_owner.AttachedTransformation()->Put2(begin, length, m_passSignal ? messageEnd : 0, blocking);}	size_t PutModifiable2(byte *begin, size_t length, int messageEnd, bool blocking)		{return m_owner.AttachedTransformation()->PutModifiable2(begin, length, m_passSignal ? messageEnd : 0, blocking);}	void Initialize(const NameValuePairs &parameters=g_nullNameValuePairs, int propagation=-1)		{if (m_passSignal) m_owner.AttachedTransformation()->Initialize(parameters, propagation);}	bool Flush(bool hardFlush, int propagation=-1, bool blocking=true)		{return m_passSignal ? m_owner.AttachedTransformation()->Flush(hardFlush, propagation, blocking) : false;}	bool MessageSeriesEnd(int propagation=-1, bool blocking=true)		{return m_passSignal ? m_owner.AttachedTransformation()->MessageSeriesEnd(propagation, blocking) : false;}	byte * ChannelCreatePutSpace(const std::string &channel, size_t &size)		{return m_owner.AttachedTransformation()->ChannelCreatePutSpace(channel, size);}	size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)		{return m_owner.AttachedTransformation()->ChannelPut2(channel, begin, length, m_passSignal ? messageEnd : 0, blocking);}	size_t ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)		{return m_owner.AttachedTransformation()->ChannelPutModifiable2(channel, begin, length, m_passSignal ? messageEnd : 0, blocking);}	bool ChannelFlush(const std::string &channel, bool completeFlush, int propagation=-1, bool blocking=true)		{return m_passSignal ? m_owner.AttachedTransformation()->ChannelFlush(channel, completeFlush, propagation, blocking) : false;}	bool ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1, bool blocking=true)		{return m_passSignal ? m_owner.AttachedTransformation()->ChannelMessageSeriesEnd(channel, propagation, blocking) : false;}private:	BufferedTransformation &m_owner;	bool m_passSignal;};//! Base class for Filter classes that are proxies for a chain of other filters.class CRYPTOPP_DLL ProxyFilter : public FilterWithBufferedInput{public:	ProxyFilter(BufferedTransformation *filter, size_t firstSize, size_t lastSize, BufferedTransformation *attachment);

⌨️ 快捷键说明

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