2015-11-05 06:59:46 +00:00
|
|
|
// dh2.cpp - written and placed in the public domain by Wei Dai
|
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
#include "dh2.h"
|
|
|
|
|
|
|
|
NAMESPACE_BEGIN(CryptoPP)
|
|
|
|
|
2016-09-16 18:51:48 +00:00
|
|
|
#if CRYPTOPP_DEBUG && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
2015-11-05 06:59:46 +00:00
|
|
|
void DH2_TestInstantiations()
|
|
|
|
{
|
|
|
|
DH2 dh(*(SimpleKeyAgreementDomain*)NULL);
|
|
|
|
}
|
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
|