Fix "warning: binding dereferenced null pointer to reference has undefined behavior"
This shows up under debug builds when testing instantiations.
warning: binding dereferenced null pointer to reference has
undefined behavior [-Wnull-dereference]
DH2 dh(*(SimpleKeyAgreementDomain*)NULLPTR);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pull/461/head
parent
b8e794cc6d
commit
5a32fbbeba
40
dh2.cpp
40
dh2.cpp
|
|
@ -1,14 +1,52 @@
|
||||||
// dh2.cpp - originally written and placed in the public domain by Wei Dai
|
// dh2.cpp - originally written and placed in the public domain by Wei Dai
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
#include "cryptlib.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "dh2.h"
|
#include "dh2.h"
|
||||||
|
|
||||||
NAMESPACE_BEGIN(CryptoPP)
|
NAMESPACE_BEGIN(CryptoPP)
|
||||||
|
|
||||||
#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
#if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
||||||
|
struct NullCryptoParameters : public CryptoParameters
|
||||||
|
{
|
||||||
|
void AssignFrom(const NameValuePairs &source) {
|
||||||
|
}
|
||||||
|
bool Validate(RandomNumberGenerator &rng, unsigned int level) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct NullSimpleKeyAgreementDomain : public TwoBases<NullCryptoParameters, SimpleKeyAgreementDomain>
|
||||||
|
{
|
||||||
|
CryptoParameters & AccessCryptoParameters() {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
unsigned int AgreedValueLength() const {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
unsigned int PrivateKeyLength() const {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
unsigned int PublicKeyLength() const {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const {
|
||||||
|
}
|
||||||
|
void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const {
|
||||||
|
}
|
||||||
|
bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void DH2_TestInstantiations()
|
void DH2_TestInstantiations()
|
||||||
{
|
{
|
||||||
DH2 dh(*(SimpleKeyAgreementDomain*)NULLPTR);
|
NullSimpleKeyAgreementDomain dom;
|
||||||
|
DH2 dh(dom);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue