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

📄 cryptlib.h

📁 lots Elliptic curve cryptography codes. Use Visual c++ to compile
💻 H
📖 第 1 页 / 共 5 页
字号:
};//! interface for asymmetric algorithms using public keysclass CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PublicKeyAlgorithm : public AsymmetricAlgorithm{public:	// VC60 workaround: no co-variant return type	CryptoMaterial & AccessMaterial() {return AccessPublicKey();}	const CryptoMaterial & GetMaterial() const {return GetPublicKey();}	virtual PublicKey & AccessPublicKey() =0;	virtual const PublicKey & GetPublicKey() const {return const_cast<PublicKeyAlgorithm *>(this)->AccessPublicKey();}};//! interface for asymmetric algorithms using private keysclass CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PrivateKeyAlgorithm : public AsymmetricAlgorithm{public:	CryptoMaterial & AccessMaterial() {return AccessPrivateKey();}	const CryptoMaterial & GetMaterial() const {return GetPrivateKey();}	virtual PrivateKey & AccessPrivateKey() =0;	virtual const PrivateKey & GetPrivateKey() const {return const_cast<PrivateKeyAlgorithm *>(this)->AccessPrivateKey();}};//! interface for key agreement algorithmsclass CRYPTOPP_DLL CRYPTOPP_NO_VTABLE KeyAgreementAlgorithm : public AsymmetricAlgorithm{public:	CryptoMaterial & AccessMaterial() {return AccessCryptoParameters();}	const CryptoMaterial & GetMaterial() const {return GetCryptoParameters();}	virtual CryptoParameters & AccessCryptoParameters() =0;	virtual const CryptoParameters & GetCryptoParameters() const {return const_cast<KeyAgreementAlgorithm *>(this)->AccessCryptoParameters();}};//! interface for public-key encryptors and decryptors/*! This class provides an interface common to encryptors and decryptors	for querying their plaintext and ciphertext lengths.*/class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_CryptoSystem{public:	virtual ~PK_CryptoSystem() {}	//! maximum length of plaintext for a given ciphertext length	/*! \note This function returns 0 if ciphertextLength is not valid (too long or too short). */	virtual size_t MaxPlaintextLength(size_t ciphertextLength) const =0;	//! calculate length of ciphertext given length of plaintext	/*! \note This function returns 0 if plaintextLength is not valid (too long). */	virtual size_t CiphertextLength(size_t plaintextLength) const =0;	//! this object supports the use of the parameter with the given name	/*! some possible parameter names: EncodingParameters, KeyDerivationParameters */	virtual bool ParameterSupported(const char *name) const =0;	//! return fixed ciphertext length, if one exists, otherwise return 0	/*! \note "Fixed" here means length of ciphertext does not depend on length of plaintext.		It usually does depend on the key length. */	virtual size_t FixedCiphertextLength() const {return 0;}	//! return maximum plaintext length given the fixed ciphertext length, if one exists, otherwise return 0	virtual size_t FixedMaxPlaintextLength() const {return 0;}#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY	size_t MaxPlainTextLength(size_t cipherTextLength) const {return MaxPlaintextLength(cipherTextLength);}	size_t CipherTextLength(size_t plainTextLength) const {return CiphertextLength(plainTextLength);}#endif};//! interface for public-key encryptorsclass CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Encryptor : public PK_CryptoSystem, public PublicKeyAlgorithm{public:	//! exception thrown when trying to encrypt plaintext of invalid length	class CRYPTOPP_DLL InvalidPlaintextLength : public Exception	{	public:		InvalidPlaintextLength() : Exception(OTHER_ERROR, "PK_Encryptor: invalid plaintext length") {}	};	//! encrypt a byte string	/*! \pre CiphertextLength(plaintextLength) != 0 (i.e., plaintext isn't too long)		\pre size of ciphertext == CiphertextLength(plaintextLength)	*/	virtual void Encrypt(RandomNumberGenerator &rng, 		const byte *plaintext, size_t plaintextLength, 		byte *ciphertext, const NameValuePairs &parameters = g_nullNameValuePairs) const =0;	//! create a new encryption filter	/*! \note The caller is responsible for deleting the returned pointer.		\note Encoding parameters should be passed in the "EP" channel.	*/	virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng, 		BufferedTransformation *attachment=NULL, const NameValuePairs &parameters = g_nullNameValuePairs) const;};//! interface for public-key decryptorsclass CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Decryptor : public PK_CryptoSystem, public PrivateKeyAlgorithm{public:	//! decrypt a byte string, and return the length of plaintext	/*! \pre size of plaintext == MaxPlaintextLength(ciphertextLength) bytes.		\return the actual length of the plaintext, indication that decryption failed.	*/	virtual DecodingResult Decrypt(RandomNumberGenerator &rng, 		const byte *ciphertext, size_t ciphertextLength, 		byte *plaintext, const NameValuePairs &parameters = g_nullNameValuePairs) const =0;	//! create a new decryption filter	/*! \note caller is responsible for deleting the returned pointer	*/	virtual BufferedTransformation * CreateDecryptionFilter(RandomNumberGenerator &rng, 		BufferedTransformation *attachment=NULL, const NameValuePairs &parameters = g_nullNameValuePairs) const;	//! decrypt a fixed size ciphertext	DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *ciphertext, byte *plaintext, const NameValuePairs &parameters = g_nullNameValuePairs) const		{return Decrypt(rng, ciphertext, FixedCiphertextLength(), plaintext, parameters);}};#ifdef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITYtypedef PK_CryptoSystem PK_FixedLengthCryptoSystem;typedef PK_Encryptor PK_FixedLengthEncryptor;typedef PK_Decryptor PK_FixedLengthDecryptor;#endif//! interface for public-key signers and verifiers/*! This class provides an interface common to signers and verifiers	for querying scheme properties.*/class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_SignatureScheme{public:	//! invalid key exception, may be thrown by any function in this class if the private or public key has a length that can't be used	class CRYPTOPP_DLL InvalidKeyLength : public Exception	{	public:		InvalidKeyLength(const std::string &message) : Exception(OTHER_ERROR, message) {}	};	//! key too short exception, may be thrown by any function in this class if the private or public key is too short to sign or verify anything	class CRYPTOPP_DLL KeyTooShort : public InvalidKeyLength	{	public:		KeyTooShort() : InvalidKeyLength("PK_Signer: key too short for this signature scheme") {}	};	virtual ~PK_SignatureScheme() {}	//! signature length if it only depends on the key, otherwise 0	virtual size_t SignatureLength() const =0;	//! maximum signature length produced for a given length of recoverable message part	virtual size_t MaxSignatureLength(size_t recoverablePartLength = 0) const {return SignatureLength();}	//! length of longest message that can be recovered, or 0 if this signature scheme does not support message recovery	virtual size_t MaxRecoverableLength() const =0;	//! length of longest message that can be recovered from a signature of given length, or 0 if this signature scheme does not support message recovery	virtual size_t MaxRecoverableLengthFromSignatureLength(size_t signatureLength) const =0;	//! requires a random number generator to sign	/*! if this returns false, NullRNG() can be passed to functions that take RandomNumberGenerator & */	virtual bool IsProbabilistic() const =0;	//! whether or not a non-recoverable message part can be signed	virtual bool AllowNonrecoverablePart() const =0;	//! if this function returns true, during verification you must input the signature before the message, otherwise you can input it at anytime */	virtual bool SignatureUpfront() const {return false;}	//! whether you must input the recoverable part before the non-recoverable part during signing	virtual bool RecoverablePartFirst() const =0;};//! interface for accumulating messages to be signed or verified/*! Only Update() should be called	on this class. No other functions inherited from HashTransformation should be called.*/class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_MessageAccumulator : public HashTransformation{public:	//! should not be called on PK_MessageAccumulator	unsigned int DigestSize() const		{throw NotImplemented("PK_MessageAccumulator: DigestSize() should not be called");}	//! should not be called on PK_MessageAccumulator	void TruncatedFinal(byte *digest, size_t digestSize) 		{throw NotImplemented("PK_MessageAccumulator: TruncatedFinal() should not be called");}};//! interface for public-key signersclass CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Signer : public PK_SignatureScheme, public PrivateKeyAlgorithm{public:	//! create a new HashTransformation to accumulate the message to be signed	virtual PK_MessageAccumulator * NewSignatureAccumulator(RandomNumberGenerator &rng) const =0;	virtual void InputRecoverableMessage(PK_MessageAccumulator &messageAccumulator, const byte *recoverableMessage, size_t recoverableMessageLength) const =0;	//! sign and delete messageAccumulator (even in case of exception thrown)	/*! \pre size of signature == MaxSignatureLength()		\return actual signature length	*/	virtual size_t Sign(RandomNumberGenerator &rng, PK_MessageAccumulator *messageAccumulator, byte *signature) const;	//! sign and restart messageAccumulator	/*! \pre size of signature == MaxSignatureLength()		\return actual signature length	*/	virtual size_t SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart=true) const =0;	//! sign a message	/*! \pre size of signature == MaxSignatureLength()		\return actual signature length	*/	virtual size_t SignMessage(RandomNumberGenerator &rng, const byte *message, size_t messageLen, byte *signature) const;	//! sign a recoverable message	/*! \pre size of signature == MaxSignatureLength(recoverableMessageLength)		\return actual signature length	*/	virtual size_t SignMessageWithRecovery(RandomNumberGenerator &rng, const byte *recoverableMessage, size_t recoverableMessageLength, 		const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, byte *signature) const;};//! interface for public-key signature verifiers/*! The Recover* functions throw NotImplemented if the signature scheme does not support	message recovery.	The Verify* functions throw InvalidDataFormat if the scheme does support message	recovery and the signature contains a non-empty recoverable message part. The	Recovery* functions should be used in that case.*/class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE PK_Verifier : public PK_SignatureScheme, public PublicKeyAlgorithm{public:	//! create a new HashTransformation to accumulate the message to be verified	virtual PK_MessageAccumulator * NewVerificationAccumulator() const =0;	//! input signature into a message accumulator	virtual void InputSignature(PK_MessageAccumulator &messageAccumulator, const byte *signature, size_t signatureLength) const =0;	//! check whether messageAccumulator contains a valid signature and message, and delete messageAccumulator (even in case of exception thrown)	virtual bool Verify(PK_MessageAccumulator *messageAccumulator) const;	//! check whether messageAccumulator contains a valid signature and message, and restart messageAccumulator	virtual bool VerifyAndRestart(PK_MessageAccumulator &messageAccumulator) const =0;	//! check whether input signature is a valid signature for input message	virtual bool VerifyMessage(const byte *message, size_t messageLen, 		const byte *signature, size_t signatureLength) const;	//! recover a message from its signature	/*! \pre size of recoveredMessage == MaxRecoverableLengthFromSignatureLength(signatureLength)	*/	virtual DecodingResult Recover(byte *recoveredMessage, PK_MessageAccumulator *messageAccumulator) const;	//! recover a message from its signature	/*! \pre size of recoveredMessage == MaxRecoverableLengthFromSignatureLength(signatureLength)	*/	virtual DecodingResult RecoverAndRestart(byte *recoveredMessage, PK_MessageAccumulator &messageAccumulator) const =0;	//! recover a message from its signature	/*! \pre size of recoveredMessage == MaxRecoverableLengthFromSignatureLength(signatureLength)	*/	virtual DecodingResult RecoverMessage(byte *recoveredMessage, 		const byte *nonrecoverableMessage, size_t nonrecoverableMessageLength, 		const byte *signature, size_t signatureLength) const;};//! interface for domains of simple key agreement protocols/*! A key agreement domain is a set of parameters that must be shared	by two parties in a key agreement protocol, along with the algorithms	for generating key pairs and deriving agreed values.*/class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE SimpleKeyAgreementDomain : public KeyAgreementAlgorithm{public:	//! return length of agreed value produced	virtual unsigned int AgreedValueLength() c

⌨️ 快捷键说明

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