Crypto++
dh2.cpp
1 // dh2.cpp - written and placed in the public domain by Wei Dai
2 
3 #include "pch.h"
4 #include "dh2.h"
5 
6 NAMESPACE_BEGIN(CryptoPP)
7 
8 void DH2_TestInstantiations()
9 {
10  DH2 dh(*(SimpleKeyAgreementDomain*)NULL);
11 }
12 
13 bool DH2::Agree(byte *agreedValue,
14  const byte *staticSecretKey, const byte *ephemeralSecretKey,
15  const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
16  bool validateStaticOtherPublicKey) const
17 {
18  return d1.Agree(agreedValue, staticSecretKey, staticOtherPublicKey, validateStaticOtherPublicKey)
19  && d2.Agree(agreedValue+d1.AgreedValueLength(), ephemeralSecretKey, ephemeralOtherPublicKey, true);
20 }
21 
22 NAMESPACE_END
virtual unsigned int AgreedValueLength() const =0
return length of agreed value produced
interface for domains of simple key agreement protocols
Definition: cryptlib.h:1431
bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const
derive agreed value from your private keys and couterparty's public keys, return false in case of fai...
Definition: dh2.cpp:13
Unified Diffie-Hellman
Definition: dh2.h:12
virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0
derive agreed value from your private key and couterparty's public key, return false in case of failu...