16 template <class GROUP_PARAMETERS, class COFACTOR_OPTION = CPP_TYPENAME GROUP_PARAMETERS::DefaultCofactorOption>
22 typedef GROUP_PARAMETERS GroupParameters;
23 typedef typename GroupParameters::Element Element;
30 : m_groupParameters(params) {}
37 {m_groupParameters.Initialize(v1, v2);}
39 template <
class T2,
class T3>
41 {m_groupParameters.Initialize(v1, v2, v3);}
43 template <
class T2,
class T3,
class T4>
45 {m_groupParameters.Initialize(v1, v2, v3, v4);}
47 template <
class T1,
class T2>
49 {m_groupParameters.Initialize(v1, v2);}
51 template <
class T1,
class T2,
class T3>
52 DH_Domain(
const T1 &v1,
const T2 &v2,
const T3 &v3)
53 {m_groupParameters.Initialize(v1, v2, v3);}
55 template <
class T1,
class T2,
class T3,
class T4>
56 DH_Domain(
const T1 &v1,
const T2 &v2,
const T3 &v3,
const T4 &v4)
57 {m_groupParameters.Initialize(v1, v2, v3, v4);}
59 const GroupParameters & GetGroupParameters()
const {
return m_groupParameters;}
60 GroupParameters & AccessGroupParameters() {
return m_groupParameters;}
64 Base::GeneratePublicKey(rng, privateKey, publicKey);
69 this->GeneratePrivateKey(rng, privateKey2);
72 Base::GeneratePublicKey(rng, privateKey2, publicKey2);
74 SecByteBlock agreedValue(this->AgreedValueLength()), agreedValue2(this->AgreedValueLength());
75 bool agreed1 = this->Agree(agreedValue, privateKey, publicKey2);
76 bool agreed2 = this->Agree(agreedValue2, privateKey2, publicKey);
78 if (!agreed1 || !agreed2 || agreedValue != agreedValue2)
79 throw SelfTestFailure(this->AlgorithmName() +
": pairwise consistency test failed");
83 static std::string CRYPTOPP_API StaticAlgorithmName()
84 {
return GroupParameters::StaticAlgorithmNamePrefix() + DH_Algorithm::StaticAlgorithmName();}
87 #ifndef CRYPTOPP_MAINTAIN_BACKWARDS_COMPATIBILITY_562 95 {
return m_groupParameters;}
97 GroupParameters m_groupParameters;
void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
generate public key
DH key agreement algorithm.
Restricts the instantiation of a class to one static object without locks.
std::string AlgorithmName() const
Provides the name of this algorithm.
interface for DL group parameters
void BERDecode(BufferedTransformation &bt)
for backwards compatibility, calls AccessMaterial().Load(bt)
Abstract base classes that provide a uniform interface to this library.
Interface for random number generators.
SecByteBlock is a SecBlock<byte> typedef.
bool FIPS_140_2_ComplianceEnabled()
Determines whether the library provides FIPS validated cryptography.
Exception thrown when a crypto algorithm is used after a self test fails.
Implementation of schemes based on DL over GF(p)
DH_Domain< DL_GroupParameters_GFP_DefaultSafePrime > DH
Diffie-Hellman in GF(p) with key validation
Crypto++ library namespace.
interface for DL key agreement algorithms