Crypto++  5.6.4
Free C++ class library of cryptographic schemes
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 #if 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 
24 NAMESPACE_END
Classes for Diffie-Hellman authenticated key exchange.
Interface for domains of simple key agreement protocols.
Definition: cryptlib.h:2689
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
virtual unsigned int AgreedValueLength() const =0
Provides the size of the agreed value.
Unified Diffie-Hellman
Definition: dh2.h:15
virtual bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const =0
Derive agreed value.
Crypto++ library namespace.