Fabcoin Core  0.16.2
P2P Digital Currency
dh2.cpp
Go to the documentation of this file.
1 // dh2.cpp - written and placed in the public domain by Wei Dai
2 
3 #include "pch.h"
4 #include "dh2.h"
5 
7 
8 #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
9 void DH2_TestInstantiations()
10 {
11  DH2 dh(*(SimpleKeyAgreementDomain*)NULL);
12 }
13 #endif
14 
15 bool DH2::Agree(byte *agreedValue,
16  const byte *staticSecretKey, const byte *ephemeralSecretKey,
17  const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
18  bool validateStaticOtherPublicKey) const
19 {
20  return d1.Agree(agreedValue, staticSecretKey, staticOtherPublicKey, validateStaticOtherPublicKey)
21  && d2.Agree(agreedValue+d1.AgreedValueLength(), ephemeralSecretKey, ephemeralOtherPublicKey, true);
22 }
23 
Classes for Unified Diffie-Hellman key exchange.
uint8_t byte
Definition: Common.h:57
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
Interface for domains of simple key agreement protocols.
Definition: cryptlib.h:2664
bool Agree(byte *agreedValue, const byte *staticPrivateKey, const byte *ephemeralPrivateKey, const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const
Derive agreed value.
Definition: dh2.cpp:15
SimpleKeyAgreementDomain & d2
Definition: dh2.h:65
Unified Diffie-Hellman in GF(p)
Definition: dh2.h:20
virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0
Derive agreed value.
SimpleKeyAgreementDomain & d1
Definition: dh2.h:65
#define NAMESPACE_END
Definition: config.h:201