File indexing completed on 2025-01-18 09:54:56
0001
0002
0003
0004
0005
0006
0007 #ifndef CRYPTOPP_DH2_H
0008 #define CRYPTOPP_DH2_H
0009
0010 #include "cryptlib.h"
0011
0012 NAMESPACE_BEGIN(CryptoPP)
0013
0014
0015
0016
0017
0018
0019
0020 class DH2 : public AuthenticatedKeyAgreementDomain
0021 {
0022 public:
0023 virtual ~DH2() {}
0024
0025
0026 DH2(SimpleKeyAgreementDomain &domain)
0027 : d1(domain), d2(domain) {}
0028
0029 DH2(SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
0030 : d1(staticDomain), d2(ephemeralDomain) {}
0031
0032 CryptoParameters & AccessCryptoParameters() {return d1.AccessCryptoParameters();}
0033
0034 unsigned int AgreedValueLength() const
0035 {return d1.AgreedValueLength() + d2.AgreedValueLength();}
0036
0037 unsigned int StaticPrivateKeyLength() const
0038 {return d1.PrivateKeyLength();}
0039 unsigned int StaticPublicKeyLength() const
0040 {return d1.PublicKeyLength();}
0041 void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
0042 {d1.GeneratePrivateKey(rng, privateKey);}
0043 void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
0044 {d1.GeneratePublicKey(rng, privateKey, publicKey);}
0045 void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
0046 {d1.GenerateKeyPair(rng, privateKey, publicKey);}
0047
0048 unsigned int EphemeralPrivateKeyLength() const
0049 {return d2.PrivateKeyLength();}
0050 unsigned int EphemeralPublicKeyLength() const
0051 {return d2.PublicKeyLength();}
0052 void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
0053 {d2.GeneratePrivateKey(rng, privateKey);}
0054 void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
0055 {d2.GeneratePublicKey(rng, privateKey, publicKey);}
0056 void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
0057 {d2.GenerateKeyPair(rng, privateKey, publicKey);}
0058
0059 bool Agree(byte *agreedValue,
0060 const byte *staticPrivateKey, const byte *ephemeralPrivateKey,
0061 const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
0062 bool validateStaticOtherPublicKey=true) const;
0063
0064 protected:
0065 SimpleKeyAgreementDomain &d1, &d2;
0066 };
0067
0068 NAMESPACE_END
0069
0070 #endif