Go to the documentation of this file.00001 #ifndef CRYPTOPP_XTRCRYPT_H
00002 #define CRYPTOPP_XTRCRYPT_H
00003
00004
00005
00006
00007
00008 #include "xtr.h"
00009
00010 NAMESPACE_BEGIN(CryptoPP)
00011
00012
00013
00014 class XTR_DH : public SimpleKeyAgreementDomain, public CryptoParameters
00015 {
00016 typedef XTR_DH ThisClass;
00017
00018 public:
00019 XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
00020 XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
00021 XTR_DH(BufferedTransformation &domainParams);
00022
00023 void DEREncode(BufferedTransformation &domainParams) const;
00024
00025 bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
00026 bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
00027 void AssignFrom(const NameValuePairs &source);
00028 CryptoParameters & AccessCryptoParameters() {return *this;}
00029 unsigned int AgreedValueLength() const {return 2*m_p.ByteCount();}
00030 unsigned int PrivateKeyLength() const {return m_q.ByteCount();}
00031 unsigned int PublicKeyLength() const {return 2*m_p.ByteCount();}
00032
00033 void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const;
00034 void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const;
00035 bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;
00036
00037 const Integer &GetModulus() const {return m_p;}
00038 const Integer &GetSubgroupOrder() const {return m_q;}
00039 const GFP2Element &GetSubgroupGenerator() const {return m_g;}
00040
00041 void SetModulus(const Integer &p) {m_p = p;}
00042 void SetSubgroupOrder(const Integer &q) {m_q = q;}
00043 void SetSubgroupGenerator(const GFP2Element &g) {m_g = g;}
00044
00045 private:
00046 unsigned int ExponentBitLength() const;
00047
00048 Integer m_p, m_q;
00049 GFP2Element m_g;
00050 };
00051
00052 NAMESPACE_END
00053
00054 #endif