2017-01-27 12:05:45 +00:00
|
|
|
// dh2.cpp - originally written and placed in the public domain by Wei Dai
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
#include "dh2.h"
|
|
|
|
|
|
|
|
NAMESPACE_BEGIN(CryptoPP)
|
|
|
|
|
2016-10-18 02:00:31 +00:00
|
|
|
#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
2015-11-05 06:59:46 +00:00
|
|
|
void DH2_TestInstantiations()
|
|
|
|
{
|
2017-03-01 11:10:06 +00:00
|
|
|
DH2 dh(*(SimpleKeyAgreementDomain*)NULLPTR);
|
2015-11-05 06:59:46 +00:00
|
|
|
}
|
2015-11-18 20:32:28 +00:00
|
|
|
#endif
|
2015-11-05 06:59:46 +00:00
|
|
|
|
|
|
|
bool DH2::Agree(byte *agreedValue,
|
2016-09-10 08:57:48 +00:00
|
|
|
const byte *staticSecretKey, const byte *ephemeralSecretKey,
|
2015-11-05 06:59:46 +00:00
|
|
|
const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
|
|
|
|
bool validateStaticOtherPublicKey) const
|
|
|
|
{
|
|
|
|
return d1.Agree(agreedValue, staticSecretKey, staticOtherPublicKey, validateStaticOtherPublicKey)
|
|
|
|
&& d2.Agree(agreedValue+d1.AgreedValueLength(), ephemeralSecretKey, ephemeralOtherPublicKey, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
NAMESPACE_END
|