00001 #ifndef CRYPTOPP_MQV_H
00002 #define CRYPTOPP_MQV_H
00003
00007 #include "modexppc.h"
00008
00009 NAMESPACE_BEGIN(CryptoPP)
00010
00012
00013 class MQV : public PK_WithPrecomputation<PK_AuthenticatedKeyAgreementDomain>
00014 {
00015 public:
00016 MQV(const Integer &p, const Integer &q, const Integer &g);
00017 MQV(RandomNumberGenerator &rng, unsigned int pbits);
00018 MQV(BufferedTransformation &domainParams);
00019
00020 void DEREncode(BufferedTransformation &domainParams) const;
00021
00022 void Precompute(unsigned int precomputationStorage=16);
00023 void LoadPrecomputation(BufferedTransformation &storedPrecomputation);
00024 void SavePrecomputation(BufferedTransformation &storedPrecomputation) const;
00025
00026 bool ValidateDomainParameters(RandomNumberGenerator &rng) const;
00027 unsigned int AgreedValueLength() const {return p.ByteCount();}
00028
00029 unsigned int StaticPrivateKeyLength() const {return q.ByteCount();}
00030 unsigned int StaticPublicKeyLength() const {return p.ByteCount();}
00031 void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
00032
00033 unsigned int EphemeralPrivateKeyLength() const {return p.ByteCount()+q.ByteCount();}
00034 unsigned int EphemeralPublicKeyLength() const {return p.ByteCount();}
00035 void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const;
00036
00037 bool Agree(byte *agreedValue,
00038 const byte *staticPrivateKey, const byte *ephemeralPrivateKey,
00039 const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
00040 bool validateStaticOtherPublicKey=true) const;
00041
00042 const Integer &Prime() const {return p;}
00043 const Integer &SubPrime() const {return q;}
00044 const Integer &Generator() const {return g;}
00045
00046 private:
00047 unsigned int ExponentBitLength() const;
00048
00049 Integer p, q, g;
00050 ModExpPrecomputation gpc;
00051 };
00052
00053 NAMESPACE_END
00054
00055 #endif