xtrcrypt.h

来自「C++实现的数字签名DSA算法」· C头文件 代码 · 共 45 行

H
45
字号
#ifndef CRYPTOPP_XTRCRYPT_H
#define CRYPTOPP_XTRCRYPT_H

/** \file
	"The XTR public key system" by Arjen K. Lenstra and Eric R. Verheul
*/

#include "xtr.h"

NAMESPACE_BEGIN(CryptoPP)

//! XTR-DH with key validation

class XTR_DH : public PK_SimpleKeyAgreementDomain
{
public:
	XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
	XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
	XTR_DH(BufferedTransformation &domainParams);

	void DEREncode(BufferedTransformation &domainParams) const;

	bool ValidateDomainParameters(RandomNumberGenerator &rng) const;
	unsigned int AgreedValueLength() const {return 2*p.ByteCount();}
	unsigned int PrivateKeyLength() const {return q.ByteCount();}
	unsigned int PublicKeyLength() const {return 2*p.ByteCount();}

	void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
	bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;

	const Integer &GetPrime() const {return p;}
	const Integer &GetSubprime() const {return q;}
	const GFP2Element &GetGenerator() const {return g;}

private:
	unsigned int ExponentBitLength() const;

	Integer p, q;
	GFP2Element g;
};

NAMESPACE_END

#endif

⌨️ 快捷键说明

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