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

📄 cryptlib.h

📁 lots Elliptic curve cryptography codes. Use Visual c++ to compile
💻 H
📖 第 1 页 / 共 5 页
字号:
// cryptlib.h - written and placed in the public domain by Wei Dai/*! \file 	This file contains the declarations for the abstract base	classes that provide a uniform interface to this library.*//*!	\mainpage Crypto++ Library 5.6.0 API Reference<dl><dt>Abstract Base Classes<dd>	cryptlib.h<dt>Authenticated Encryption<dd>	AuthenticatedSymmetricCipherDocumentation<dt>Symmetric Ciphers<dd>	SymmetricCipherDocumentation<dt>Hash Functions<dd>	SHA1, SHA224, SHA256, SHA384, SHA512, Tiger, Whirlpool, RIPEMD160, RIPEMD320, RIPEMD128, RIPEMD256, Weak1::MD2, Weak1::MD4, Weak1::MD5<dt>Non-Cryptographic Checksums<dd>	CRC32, Adler32<dt>Message Authentication Codes<dd>	VMAC, HMAC, CBC_MAC, CMAC, DMAC, TTMAC, GCM (GMAC)<dt>Random Number Generators<dd>	NullRNG(), LC_RNG, RandomPool, BlockingRng, NonblockingRng, AutoSeededRandomPool, AutoSeededX917RNG, DefaultAutoSeededRNG<dt>Password-based Cryptography<dd>	PasswordBasedKeyDerivationFunction<dt>Public Key Cryptosystems<dd>	DLIES, ECIES, LUCES, RSAES, RabinES, LUC_IES<dt>Public Key Signature Schemes<dd>	DSA, GDSA, ECDSA, NR, ECNR, LUCSS, RSASS, RSASS_ISO, RabinSS, RWSS, ESIGN<dt>Key Agreement<dd>	#DH, DH2, #MQV, ECDH, ECMQV, XTR_DH<dt>Algebraic Structures<dd>	Integer, PolynomialMod2, PolynomialOver, RingOfPolynomialsOver,	ModularArithmetic, MontgomeryRepresentation, GFP2_ONB,	GF2NP, GF256, GF2_32, EC2N, ECP<dt>Secret Sharing and Information Dispersal<dd>	SecretSharing, SecretRecovery, InformationDispersal, InformationRecovery<dt>Compression<dd>	Deflator, Inflator, Gzip, Gunzip, ZlibCompressor, ZlibDecompressor<dt>Input Source Classes<dd>	StringSource, ArraySource, FileSource, SocketSource, WindowsPipeSource, RandomNumberSource<dt>Output Sink Classes<dd>	StringSinkTemplate, ArraySink, FileSink, SocketSink, WindowsPipeSink, RandomNumberSink<dt>Filter Wrappers<dd>	StreamTransformationFilter, HashFilter, HashVerificationFilter, SignerFilter, SignatureVerificationFilter<dt>Binary to Text Encoders and Decoders<dd>	HexEncoder, HexDecoder, Base64Encoder, Base64Decoder, Base32Encoder, Base32Decoder<dt>Wrappers for OS features<dd>	Timer, Socket, WindowsHandle, ThreadLocalStorage, ThreadUserTimer<dt>FIPS 140 related<dd>	fips140.h</dl>In the FIPS 140-2 validated DLL version of Crypto++, only the following implementation class are available.<dl><dt>Block Ciphers<dd>	AES, DES_EDE2, DES_EDE3, SKIPJACK<dt>Cipher Modes (replace template parameter BC with one of the block ciphers above)<dd>	ECB_Mode\<BC\>, CTR_Mode\<BC\>, CBC_Mode\<BC\>, CFB_FIPS_Mode\<BC\>, OFB_Mode\<BC\><dt>Hash Functions<dd>	SHA1, SHA224, SHA256, SHA384, SHA512<dt>Public Key Signature Schemes (replace template parameter H with one of the hash functions above)<dd>	RSASS\<PKCS1v15, H\>, RSASS\<PSS, H\>, RSASS_ISO\<H\>, RWSS\<P1363_EMSA2, H\>, DSA, ECDSA\<ECP, H\>, ECDSA\<EC2N, H\><dt>Message Authentication Codes (replace template parameter H with one of the hash functions above)<dd>	HMAC\<H\>, CBC_MAC\<DES_EDE2\>, CBC_MAC\<DES_EDE3\><dt>Random Number Generators<dd>	DefaultAutoSeededRNG (AutoSeededX917RNG\<AES\>)<dt>Key Agreement<dd>	#DH<dt>Public Key Cryptosystems<dd>	RSAES\<OAEP\<SHA1\> \></dl><p>This reference manual is a work in progress. Some classes are still lacking detailed descriptions.<p>Click <a href="CryptoPPRef.zip">here</a> to download a zip archive containing this manual.<p>Thanks to Ryan Phillips for providing the Doxygen configuration fileand getting me started with this manual.*/#ifndef CRYPTOPP_CRYPTLIB_H#define CRYPTOPP_CRYPTLIB_H#include "config.h"#include "stdcpp.h"NAMESPACE_BEGIN(CryptoPP)// forward declarationsclass Integer;class RandomNumberGenerator;class BufferedTransformation;//! used to specify a direction for a cipher to operate in (encrypt or decrypt)enum CipherDir {ENCRYPTION, DECRYPTION};//! used to represent infinite timeconst unsigned long INFINITE_TIME = ULONG_MAX;// VC60 workaround: using enums as template parameters causes problemstemplate <typename ENUM_TYPE, int VALUE>struct EnumToType{	static ENUM_TYPE ToEnum() {return (ENUM_TYPE)VALUE;}};enum ByteOrder {LITTLE_ENDIAN_ORDER = 0, BIG_ENDIAN_ORDER = 1};typedef EnumToType<ByteOrder, LITTLE_ENDIAN_ORDER> LittleEndian;typedef EnumToType<ByteOrder, BIG_ENDIAN_ORDER> BigEndian;//! base class for all exceptions thrown by Crypto++class CRYPTOPP_DLL Exception : public std::exception{public:	//! error types	enum ErrorType {		//! a method is not implemented		NOT_IMPLEMENTED,		//! invalid function argument		INVALID_ARGUMENT,		//! BufferedTransformation received a Flush(true) signal but can't flush buffers		CANNOT_FLUSH,		//! data integerity check (such as CRC or MAC) failed		DATA_INTEGRITY_CHECK_FAILED,		//! received input data that doesn't conform to expected format		INVALID_DATA_FORMAT,		//! error reading from input device or writing to output device		IO_ERROR,		//! some error not belong to any of the above categories		OTHER_ERROR	};	explicit Exception(ErrorType errorType, const std::string &s) : m_errorType(errorType), m_what(s) {}	virtual ~Exception() throw() {}	const char *what() const throw() {return (m_what.c_str());}	const std::string &GetWhat() const {return m_what;}	void SetWhat(const std::string &s) {m_what = s;}	ErrorType GetErrorType() const {return m_errorType;}	void SetErrorType(ErrorType errorType) {m_errorType = errorType;}private:	ErrorType m_errorType;	std::string m_what;};//! exception thrown when an invalid argument is detectedclass CRYPTOPP_DLL InvalidArgument : public Exception{public:	explicit InvalidArgument(const std::string &s) : Exception(INVALID_ARGUMENT, s) {}};//! exception thrown when input data is received that doesn't conform to expected formatclass CRYPTOPP_DLL InvalidDataFormat : public Exception{public:	explicit InvalidDataFormat(const std::string &s) : Exception(INVALID_DATA_FORMAT, s) {}};//! exception thrown by decryption filters when trying to decrypt an invalid ciphertextclass CRYPTOPP_DLL InvalidCiphertext : public InvalidDataFormat{public:	explicit InvalidCiphertext(const std::string &s) : InvalidDataFormat(s) {}};//! exception thrown by a class if a non-implemented method is calledclass CRYPTOPP_DLL NotImplemented : public Exception{public:	explicit NotImplemented(const std::string &s) : Exception(NOT_IMPLEMENTED, s) {}};//! exception thrown by a class when Flush(true) is called but it can't completely flush its buffersclass CRYPTOPP_DLL CannotFlush : public Exception{public:	explicit CannotFlush(const std::string &s) : Exception(CANNOT_FLUSH, s) {}};//! error reported by the operating systemclass CRYPTOPP_DLL OS_Error : public Exception{public:	OS_Error(ErrorType errorType, const std::string &s, const std::string& operation, int errorCode)		: Exception(errorType, s), m_operation(operation), m_errorCode(errorCode) {}	~OS_Error() throw() {}	// the operating system API that reported the error	const std::string & GetOperation() const {return m_operation;}	// the error code return by the operating system	int GetErrorCode() const {return m_errorCode;}protected:	std::string m_operation;	int m_errorCode;};//! used to return decoding resultsstruct CRYPTOPP_DLL DecodingResult{	explicit DecodingResult() : isValidCoding(false), messageLength(0) {}	explicit DecodingResult(size_t len) : isValidCoding(true), messageLength(len) {}	bool operator==(const DecodingResult &rhs) const {return isValidCoding == rhs.isValidCoding && messageLength == rhs.messageLength;}	bool operator!=(const DecodingResult &rhs) const {return !operator==(rhs);}	bool isValidCoding;	size_t messageLength;#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY	operator size_t() const {return isValidCoding ? messageLength : 0;}#endif};//! interface for retrieving values given their names/*! \note This class is used to safely pass a variable number of arbitrarily typed arguments to functions	and to read values from keys and crypto parameters.	\note To obtain an object that implements NameValuePairs for the purpose of parameter	passing, use the MakeParameters() function.	\note To get a value from NameValuePairs, you need to know the name and the type of the value. 	Call GetValueNames() on a NameValuePairs object to obtain a list of value names that it supports.	Then look at the Name namespace documentation to see what the type of each value is, or	alternatively, call GetIntValue() with the value name, and if the type is not int, a	ValueTypeMismatch exception will be thrown and you can get the actual type from the exception object.*/class CRYPTOPP_NO_VTABLE NameValuePairs{public:	virtual ~NameValuePairs() {}	//! exception thrown when trying to retrieve a value using a different type than expected	class CRYPTOPP_DLL ValueTypeMismatch : public InvalidArgument	{	public:		ValueTypeMismatch(const std::string &name, const std::type_info &stored, const std::type_info &retrieving)			: InvalidArgument("NameValuePairs: type mismatch for '" + name + "', stored '" + stored.name() + "', trying to retrieve '" + retrieving.name() + "'")			, m_stored(stored), m_retrieving(retrieving) {}		const std::type_info & GetStoredTypeInfo() const {return m_stored;}		const std::type_info & GetRetrievingTypeInfo() const {return m_retrieving;}	private:		const std::type_info &m_stored;		const std::type_info &m_retrieving;	};	//! get a copy of this object or a subobject of it	template <class T>	bool GetThisObject(T &object) const	{		return GetValue((std::string("ThisObject:")+typeid(T).name()).c_str(), object);	}	//! get a pointer to this object, as a pointer to T	template <class T>	bool GetThisPointer(T *&p) const	{		return GetValue((std::string("ThisPointer:")+typeid(T).name()).c_str(), p);	}	//! get a named value, returns true if the name exists	template <class T>	bool GetValue(const char *name, T &value) const	{		return GetVoidValue(name, typeid(T), &value);	}	//! get a named value, returns the default if the name doesn't exist	template <class T>	T GetValueWithDefault(const char *name, T defaultValue) const	{		GetValue(name, defaultValue);		return defaultValue;	}	//! get a list of value names that can be retrieved	CRYPTOPP_DLL std::string GetValueNames() const		{std::string result; GetValue("ValueNames", result); return result;}	//! get a named value with type int	/*! used to ensure we don't accidentally try to get an unsigned int		or some other type when we mean int (which is the most common case) */	CRYPTOPP_DLL bool GetIntValue(const char *name, int &value) const		{return GetValue(name, value);}	//! get a named value with type int, with default	CRYPTOPP_DLL int GetIntValueWithDefault(const char *name, int defaultValue) const		{return GetValueWithDefault(name, defaultValue);}	//! used by derived classes to check for type mismatch	CRYPTOPP_DLL static void CRYPTOPP_API ThrowIfTypeMismatch(const char *name, const std::type_info &stored, const std::type_info &retrieving)

⌨️ 快捷键说明

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