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