00001 #ifndef CRYPTOPP_XTRCRYPT_H
00002 #define CRYPTOPP_XTRCRYPT_H
00003
00008 #include "xtr.h"
00009
00010 NAMESPACE_BEGIN(CryptoPP)
00011
00013
00014 class XTR_DH : public PK_SimpleKeyAgreementDomain
00015 {
00016 public:
00017 XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
00018 XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
00019 XTR_DH(BufferedTransformation &domainParams);
00020
00021 void DEREncode(BufferedTransformation &domainParams) const;
00022
00023 bool ValidateDomainParameters(RandomNumberGenerator &rng) const;
00024 unsigned int AgreedValueLength() const {return 2*p.ByteCount();}
00025 unsigned int PrivateKeyLength() const {return q.ByteCount();}
00026 unsigned int PublicKeyLength() const {return 2*p.ByteCount();}
00027
00028 void GenerateKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
00029 bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;
00030
00031 const Integer &GetPrime() const {return p;}
00032 const Integer &GetSubprime() const {return q;}
00033 const GFP2Element &GetGenerator() const {return g;}
00034
00035 private:
00036 unsigned int ExponentBitLength() const;
00037
00038 Integer p, q;
00039 GFP2Element g;
00040 };
00041
00042 NAMESPACE_END
00043
00044 #endif