00001
00002
00003
00004
00005
00006
00007 #ifndef CRYPTOPP_DH2_H
00008 #define CRYPTOPP_DH2_H
00009
00010 #include "cryptlib.h"
00011
00012 NAMESPACE_BEGIN(CryptoPP)
00013
00014
00015 class DH2 : public AuthenticatedKeyAgreementDomain
00016 {
00017 public:
00018 DH2(SimpleKeyAgreementDomain &domain)
00019 : d1(domain), d2(domain) {}
00020 DH2(SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
00021 : d1(staticDomain), d2(ephemeralDomain) {}
00022
00023 CryptoParameters & AccessCryptoParameters() {return d1.AccessCryptoParameters();}
00024
00025 unsigned int AgreedValueLength() const
00026 {return d1.AgreedValueLength() + d2.AgreedValueLength();}
00027
00028 unsigned int StaticPrivateKeyLength() const
00029 {return d1.PrivateKeyLength();}
00030 unsigned int StaticPublicKeyLength() const
00031 {return d1.PublicKeyLength();}
00032 void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
00033 {d1.GeneratePrivateKey(rng, privateKey);}
00034 void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
00035 {d1.GeneratePublicKey(rng, privateKey, publicKey);}
00036 void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
00037 {d1.GenerateKeyPair(rng, privateKey, publicKey);}
00038
00039 unsigned int EphemeralPrivateKeyLength() const
00040 {return d2.PrivateKeyLength();}
00041 unsigned int EphemeralPublicKeyLength() const
00042 {return d2.PublicKeyLength();}
00043 void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
00044 {d2.GeneratePrivateKey(rng, privateKey);}
00045 void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
00046 {d2.GeneratePublicKey(rng, privateKey, publicKey);}
00047 void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
00048 {d2.GenerateKeyPair(rng, privateKey, publicKey);}
00049
00050 bool Agree(byte *agreedValue,
00051 const byte *staticPrivateKey, const byte *ephemeralPrivateKey,
00052 const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
00053 bool validateStaticOtherPublicKey=true) const;
00054
00055 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562
00056 virtual ~DH2() {}
00057 #endif
00058
00059 protected:
00060 SimpleKeyAgreementDomain &d1, &d2;
00061 };
00062
00063 NAMESPACE_END
00064
00065 #endif