File indexing completed on 2025-01-18 09:55:10
0001 #ifndef CRYPTOPP_XTRCRYPT_H
0002 #define CRYPTOPP_XTRCRYPT_H
0003
0004
0005
0006
0007
0008 #include "cryptlib.h"
0009 #include "xtr.h"
0010 #include "integer.h"
0011
0012 NAMESPACE_BEGIN(CryptoPP)
0013
0014
0015 class XTR_DH : public SimpleKeyAgreementDomain, public CryptoParameters
0016 {
0017 typedef XTR_DH ThisClass;
0018
0019 public:
0020 XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
0021 XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
0022 XTR_DH(BufferedTransformation &domainParams);
0023
0024 void DEREncode(BufferedTransformation &domainParams) const;
0025
0026 bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
0027 bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
0028 void AssignFrom(const NameValuePairs &source);
0029 CryptoParameters & AccessCryptoParameters() {return *this;}
0030 unsigned int AgreedValueLength() const {return 2*m_p.ByteCount();}
0031 unsigned int PrivateKeyLength() const {return m_q.ByteCount();}
0032 unsigned int PublicKeyLength() const {return 2*m_p.ByteCount();}
0033
0034 void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const;
0035 void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const;
0036 bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;
0037
0038 const Integer &GetModulus() const {return m_p;}
0039 const Integer &GetSubgroupOrder() const {return m_q;}
0040 const GFP2Element &GetSubgroupGenerator() const {return m_g;}
0041
0042 void SetModulus(const Integer &p) {m_p = p;}
0043 void SetSubgroupOrder(const Integer &q) {m_q = q;}
0044 void SetSubgroupGenerator(const GFP2Element &g) {m_g = g;}
0045
0046 private:
0047 unsigned int ExponentBitLength() const;
0048
0049 Integer m_p, m_q;
0050 GFP2Element m_g;
0051 };
0052
0053 NAMESPACE_END
0054
0055 #endif