From 5efb019d8bdc593b3c1a0b57d615b170c7dab02a Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 1 Mar 2017 06:10:06 -0500 Subject: [PATCH] Add C++ nullptr support (Issue 383) --- algparam.cpp | 2 +- algparam.h | 16 +++++------ asn.h | 4 +-- base32.h | 4 +-- base64.h | 8 +++--- basecode.h | 20 +++++++------- bench1.cpp | 12 ++++----- blake2.cpp | 6 ++--- blake2.h | 8 +++--- channels.cpp | 4 +-- config.h | 23 ++++++++++++++++ cpu.cpp | 32 +++++++++++----------- cryptlib.cpp | 4 +-- cryptlib.h | 30 ++++++++++----------- datatest.cpp | 10 +++---- default.cpp | 24 ++++++++--------- default.h | 16 +++++------ dh2.cpp | 2 +- dll.cpp | 10 +++---- dlltest.cpp | 4 +-- drbg.h | 28 ++++++++++---------- eccrypto.h | 4 +-- factory.h | 14 +++++----- fhmqv.h | 10 +++---- files.cpp | 12 ++++----- files.h | 16 +++++------ filters.cpp | 18 ++++++------- filters.h | 62 +++++++++++++++++++++---------------------- fips140.cpp | 2 +- fips140.h | 2 +- fipsalgt.cpp | 8 +++--- fipstest.cpp | 28 ++++++++++---------- fltrimpl.h | 2 +- gcm.cpp | 12 ++++----- gf2n.cpp | 2 +- gfpcrypt.cpp | 2 +- gfpcrypt.h | 2 +- gzip.h | 6 ++--- hex.h | 4 +-- hkdf.h | 4 +-- hmqv.h | 12 ++++----- hrtimer.cpp | 2 +- ida.cpp | 6 ++--- ida.h | 12 ++++----- integer.cpp | 6 ++--- keccak.cpp | 2 +- misc.cpp | 30 ++++++++++----------- misc.h | 14 +++++----- modes.cpp | 4 +-- modes.h | 6 ++--- mqueue.h | 2 +- network.cpp | 18 ++++++------- osrng.h | 4 +-- ossig.h | 2 +- panama.cpp | 6 ++--- panama.h | 4 +-- poly1305.cpp | 2 +- poly1305.h | 2 +- pubkey.cpp | 4 +-- pubkey.h | 10 +++---- queue.cpp | 10 +++---- queue.h | 3 +-- randpool.cpp | 2 +- rdrand.cpp | 4 +-- rijndael.cpp | 2 +- rng.cpp | 4 +-- rng.h | 4 +-- secblock.h | 22 +++++++-------- sha3.cpp | 2 +- simple.h | 2 +- siphash.h | 2 +- smartptr.h | 20 +++++++------- socketft.cpp | 36 ++++++++++++------------- socketft.h | 6 ++--- strciphr.h | 8 +++--- test.cpp | 20 +++++++------- trdlocal.cpp | 2 +- validat0.cpp | 16 +++++------ validat1.cpp | 36 ++++++++++++------------- validat2.cpp | 6 ++--- validat3.cpp | 75 ++++++++++++++++++++++++++-------------------------- vmac.cpp | 2 +- vmac.h | 2 +- wait.cpp | 10 +++---- wait.h | 2 +- winpipes.cpp | 4 +-- winpipes.h | 2 +- zdeflate.cpp | 2 +- zdeflate.h | 4 +-- zinflate.cpp | 4 +-- zinflate.h | 2 +- zlib.h | 6 ++--- 92 files changed, 484 insertions(+), 463 deletions(-) diff --git a/algparam.cpp b/algparam.cpp index 79ebcc9d..b6b0b34e 100644 --- a/algparam.cpp +++ b/algparam.cpp @@ -9,7 +9,7 @@ NAMESPACE_BEGIN(CryptoPP) -PAssignIntToInteger g_pAssignIntToInteger = NULL; +PAssignIntToInteger g_pAssignIntToInteger = NULLPTR; bool CombinedNameValuePairs::GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const { diff --git a/algparam.h b/algparam.h index 58af9eed..9e274f49 100644 --- a/algparam.h +++ b/algparam.h @@ -34,8 +34,8 @@ public: //! \param deepCopy flag indicating whether the data should be copied //! \details The deepCopy option is used when the NameValuePairs object can't //! keep a copy of the data available - ConstByteArrayParameter(const char *data = NULL, bool deepCopy = false) - : m_deepCopy(false), m_data(NULL), m_size(0) + ConstByteArrayParameter(const char *data = NULLPTR, bool deepCopy = false) + : m_deepCopy(false), m_data(NULLPTR), m_size(0) { Assign((const byte *)data, data ? strlen(data) : 0, deepCopy); } @@ -47,7 +47,7 @@ public: //! \details The deepCopy option is used when the NameValuePairs object can't //! keep a copy of the data available ConstByteArrayParameter(const byte *data, size_t size, bool deepCopy = false) - : m_deepCopy(false), m_data(NULL), m_size(0) + : m_deepCopy(false), m_data(NULLPTR), m_size(0) { Assign(data, size, deepCopy); } @@ -59,7 +59,7 @@ public: //! \details The deepCopy option is used when the NameValuePairs object can't //! keep a copy of the data available template ConstByteArrayParameter(const T &string, bool deepCopy = false) - : m_deepCopy(false), m_data(NULL), m_size(0) + : m_deepCopy(false), m_data(NULLPTR), m_size(0) { CRYPTOPP_COMPILE_ASSERT(sizeof(typename T::value_type) == 1); Assign((const byte *)string.data(), string.size(), deepCopy); @@ -107,7 +107,7 @@ public: //! \brief Construct a ByteArrayParameter //! \param data a memory buffer //! \param size the length of the memory buffer - ByteArrayParameter(byte *data = NULL, unsigned int size = 0) + ByteArrayParameter(byte *data = NULLPTR, unsigned int size = 0) : m_data(data), m_size(size) {} //! \brief Construct a ByteArrayParameter @@ -221,13 +221,13 @@ private: }; template -GetValueHelperClass GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL) +GetValueHelperClass GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULLPTR) { return GetValueHelperClass(pObject, name, valueType, pValue, searchFirst); } template -GetValueHelperClass GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULL) +GetValueHelperClass GetValueHelper(const T *pObject, const char *name, const std::type_info &valueType, void *pValue, const NameValuePairs *searchFirst=NULLPTR) { return GetValueHelperClass(pObject, name, valueType, pValue, searchFirst); } @@ -387,7 +387,7 @@ public: void AssignValue(const char *name, const std::type_info &valueType, void *pValue) const { // special case for retrieving an Integer parameter when an int was passed in - if (!(g_pAssignIntToInteger != NULL && typeid(T) == typeid(int) && g_pAssignIntToInteger(valueType, pValue, &m_value))) + if (!(g_pAssignIntToInteger != NULLPTR && typeid(T) == typeid(int) && g_pAssignIntToInteger(valueType, pValue, &m_value))) { NameValuePairs::ThrowIfTypeMismatch(name, typeid(T), valueType); *reinterpret_cast(pValue) = m_value; diff --git a/asn.h b/asn.h index f05209ec..c3d852ed 100644 --- a/asn.h +++ b/asn.h @@ -220,7 +220,7 @@ public: //! \param attachment a BufferedTrasformation to attach to this object //! \param nObjects //! \param flags bitwise OR of EncodedObjectFilter::Flag - EncodedObjectFilter(BufferedTransformation *attachment = NULL, unsigned int nObjects = 1, word32 flags = 0); + EncodedObjectFilter(BufferedTransformation *attachment = NULLPTR, unsigned int nObjects = 1, word32 flags = 0); //! \brief Input a byte buffer for processing //! \param inString the byte buffer to process @@ -361,7 +361,7 @@ public: //! \param out BufferedTransformation object void DEREncode(BufferedTransformation &out) { - if (this->get() != NULL) + if (this->get() != NULLPTR) this->get()->DEREncode(out); } }; diff --git a/base32.h b/base32.h index 05d68764..b0f3094c 100644 --- a/base32.h +++ b/base32.h @@ -26,7 +26,7 @@ public: //! \details Base32Encoder() constructs a default encoder. The constructor lacks fields for padding and //! line breaks. You must use IsolatedInitialize() to change the default padding character or suppress it. //! \sa IsolatedInitialize() for an example of modifying a Base32Encoder after construction. - Base32Encoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "") + Base32Encoder(BufferedTransformation *attachment = NULLPTR, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "") : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment) { IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), groupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator))); @@ -64,7 +64,7 @@ public: //! \brief Construct a Base32Decoder //! \param attachment a BufferedTrasformation to attach to this object //! \sa IsolatedInitialize() for an example of modifying a Base32Decoder after construction. - Base32Decoder(BufferedTransformation *attachment = NULL) + Base32Decoder(BufferedTransformation *attachment = NULLPTR) : BaseN_Decoder(GetDefaultDecodingLookupArray(), 5, attachment) {} //! \brief Initialize or reinitialize this object, without signal propagation diff --git a/base64.h b/base64.h index 54961bd6..5213f89e 100644 --- a/base64.h +++ b/base64.h @@ -24,7 +24,7 @@ public: //! \details Base64Encoder constructs a default encoder. The constructor lacks a parameter for padding, and you must //! use IsolatedInitialize() to modify the Base64Encoder after construction. //! \sa IsolatedInitialize() for an example of modifying an encoder after construction. - Base64Encoder(BufferedTransformation *attachment = NULL, bool insertLineBreaks = true, int maxLineLength = 72) + Base64Encoder(BufferedTransformation *attachment = NULLPTR, bool insertLineBreaks = true, int maxLineLength = 72) : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment) { IsolatedInitialize(MakeParameters(Name::InsertLineBreaks(), insertLineBreaks)(Name::MaxLineLength(), maxLineLength)); @@ -62,7 +62,7 @@ public: //! \brief Construct a Base64Decoder //! \param attachment a BufferedTrasformation to attach to this object //! \sa IsolatedInitialize() for an example of modifying an encoder after construction. - Base64Decoder(BufferedTransformation *attachment = NULL) + Base64Decoder(BufferedTransformation *attachment = NULLPTR) : BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) {} //! \brief Initialize or reinitialize this object, without signal propagation @@ -109,7 +109,7 @@ public: //! after constructing a Base64URLEncoder. //! \sa Base64Encoder for an encoder that provides a classic alphabet, and Base64URLEncoder::IsolatedInitialize //! for an example of modifying an encoder after construction. - Base64URLEncoder(BufferedTransformation *attachment = NULL, bool insertLineBreaks = false, int maxLineLength = -1) + Base64URLEncoder(BufferedTransformation *attachment = NULLPTR, bool insertLineBreaks = false, int maxLineLength = -1) : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment) { CRYPTOPP_UNUSED(insertLineBreaks), CRYPTOPP_UNUSED(maxLineLength); @@ -139,7 +139,7 @@ public: //! \param attachment a BufferedTrasformation to attach to this object //! \details Base64URLDecoder() constructs a default decoder using a web safe alphabet. //! \sa Base64Decoder for a decoder that provides a classic alphabet. - Base64URLDecoder(BufferedTransformation *attachment = NULL) + Base64URLDecoder(BufferedTransformation *attachment = NULLPTR) : BaseN_Decoder(GetDecodingLookupArray(), 6, attachment) {} //! \brief Initialize or reinitialize this object, without signal propagation diff --git a/basecode.h b/basecode.h index 2e617eb4..a522d6db 100644 --- a/basecode.h +++ b/basecode.h @@ -20,8 +20,8 @@ class CRYPTOPP_DLL BaseN_Encoder : public Unflushable public: //! \brief Construct a BaseN_Encoder //! \param attachment a BufferedTransformation to attach to this object - BaseN_Encoder(BufferedTransformation *attachment=NULL) - : m_alphabet(NULL), m_padding(0), m_bitsPerChar(0) + BaseN_Encoder(BufferedTransformation *attachment=NULLPTR) + : m_alphabet(NULLPTR), m_padding(0), m_bitsPerChar(0) , m_outputBlockSize(0), m_bytePos(0), m_bitPos(0) {Detach(attachment);} @@ -32,8 +32,8 @@ public: //! \param padding the character to use as padding //! \pre log2base must be between 1 and 7 inclusive //! \throws InvalidArgument if log2base is not between 1 and 7 - BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULL, int padding=-1) - : m_alphabet(NULL), m_padding(0), m_bitsPerChar(0) + BaseN_Encoder(const byte *alphabet, int log2base, BufferedTransformation *attachment=NULLPTR, int padding=-1) + : m_alphabet(NULLPTR), m_padding(0), m_bitsPerChar(0) , m_outputBlockSize(0), m_bytePos(0), m_bitPos(0) { Detach(attachment); @@ -62,8 +62,8 @@ public: //! \param attachment a BufferedTransformation to attach to this object //! \details padding is set to -1, which means use default padding. If not //! required, then the value must be set via IsolatedInitialize(). - BaseN_Decoder(BufferedTransformation *attachment=NULL) - : m_lookup(0), m_padding(0), m_bitsPerChar(0) + BaseN_Decoder(BufferedTransformation *attachment=NULLPTR) + : m_lookup(NULLPTR), m_padding(0), m_bitsPerChar(0) , m_outputBlockSize(0), m_bytePos(0), m_bitPos(0) {Detach(attachment);} @@ -75,8 +75,8 @@ public: //! the number of elements (like 32). //! \details padding is set to -1, which means use default padding. If not //! required, then the value must be set via IsolatedInitialize(). - BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULL) - : m_lookup(0), m_padding(0), m_bitsPerChar(0) + BaseN_Decoder(const int *lookup, int log2base, BufferedTransformation *attachment=NULLPTR) + : m_lookup(NULLPTR), m_padding(0), m_bitsPerChar(0) , m_outputBlockSize(0), m_bytePos(0), m_bitPos(0) { Detach(attachment); @@ -112,7 +112,7 @@ class CRYPTOPP_DLL Grouper : public Bufferless public: //! \brief Construct a Grouper //! \param attachment a BufferedTransformation to attach to this object - Grouper(BufferedTransformation *attachment=NULL) + Grouper(BufferedTransformation *attachment=NULLPTR) : m_groupSize(0), m_counter(0) {Detach(attachment);} //! \brief Construct a Grouper @@ -120,7 +120,7 @@ public: //! \param separator the separator to use between groups //! \param terminator the terminator appeand after processing //! \param attachment a BufferedTransformation to attach to this object - Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULL) + Grouper(int groupSize, const std::string &separator, const std::string &terminator, BufferedTransformation *attachment=NULLPTR) : m_groupSize(0), m_counter(0) { Detach(attachment); diff --git a/bench1.cpp b/bench1.cpp index be25f3dd..431ed130 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -94,7 +94,7 @@ void BenchMark(const char *name, BlockTransformation &cipher, double timeTotal) { blocks *= 2; for (; i -void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs) +void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char *displayName=NULLPTR, const NameValuePairs ¶ms = g_nullNameValuePairs) { CRYPTOPP_UNUSED(params); std::string name(factoryName ? factoryName : ""); @@ -212,14 +212,14 @@ void BenchMarkByName2(const char *factoryName, size_t keyLength = 0, const char } template -void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs) +void BenchMarkByName(const char *factoryName, size_t keyLength = 0, const char *displayName=NULLPTR, const NameValuePairs ¶ms = g_nullNameValuePairs) { CRYPTOPP_UNUSED(params); BenchMarkByName2(factoryName, keyLength, displayName, params); } template -void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULL, const NameValuePairs ¶ms = g_nullNameValuePairs) +void BenchMarkByNameKeyLess(const char *factoryName, const char *displayName=NULLPTR, const NameValuePairs ¶ms = g_nullNameValuePairs) { CRYPTOPP_UNUSED(params); std::string name = factoryName; @@ -373,7 +373,7 @@ void BenchmarkAll(double t, double hertz) char timeBuf[64]; errno_t err; - const time_t endTime = time(NULL); + const time_t endTime = time(NULLPTR); err = localtime_s(&localTime, &endTime); CRYPTOPP_ASSERT(err == 0); err = asctime_s(timeBuf, sizeof(timeBuf), &localTime); @@ -381,7 +381,7 @@ void BenchmarkAll(double t, double hertz) std::cout << "\nTest ended at " << timeBuf; #else - const time_t endTime = time(NULL); + const time_t endTime = time(NULLPTR); std::cout << "\nTest ended at " << asctime(localtime(&endTime)); #endif #endif diff --git a/blake2.cpp b/blake2.cpp index 0bdaeab7..dd9de2e5 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -342,7 +342,7 @@ void BLAKE2_Base::UncheckedSetKey(const byte *key, unsigned int leng template BLAKE2_Base::BLAKE2_Base() : m_state(1), m_block(1), m_digestSize(DIGESTSIZE), m_treeMode(false) { - UncheckedSetKey(NULL, 0, g_nullNameValuePairs); + UncheckedSetKey(NULLPTR, 0, g_nullNameValuePairs); Restart(); } @@ -351,7 +351,7 @@ BLAKE2_Base::BLAKE2_Base(bool treeMode, unsigned int digestSize) : m { CRYPTOPP_ASSERT(digestSize <= DIGESTSIZE); - UncheckedSetKey(NULL, 0, g_nullNameValuePairs); + UncheckedSetKey(NULLPTR, 0, g_nullNameValuePairs); Restart(); } @@ -392,7 +392,7 @@ void BLAKE2_Base::Restart(const BLAKE2_ParameterBlock& bloc State& state = *m_state.data(); state.t[0] = state.t[1] = 0, state.f[0] = state.f[1] = 0, state.length = 0; - if (counter != NULL) + if (counter != NULLPTR) { state.t[0] = counter[0]; state.t[1] = counter[1]; diff --git a/blake2.h b/blake2.h index 76692e31..b3402001 100644 --- a/blake2.h +++ b/blake2.h @@ -266,8 +266,8 @@ public: //! \param personalizationLength the size of the byte array //! \param treeMode flag indicating tree mode //! \param digestSize the digest size, in bytes - BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULL, size_t saltLength = 0, - const byte* personalization = NULL, size_t personalizationLength = 0, + BLAKE2b(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0, + const byte* personalization = NULLPTR, size_t personalizationLength = 0, bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} }; @@ -302,8 +302,8 @@ public: //! \param personalizationLength the size of the byte array //! \param treeMode flag indicating tree mode //! \param digestSize the digest size, in bytes - BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULL, size_t saltLength = 0, - const byte* personalization = NULL, size_t personalizationLength = 0, + BLAKE2s(const byte *key, size_t keyLength, const byte* salt = NULLPTR, size_t saltLength = 0, + const byte* personalization = NULLPTR, size_t personalizationLength = 0, bool treeMode=false, unsigned int digestSize = DIGESTSIZE) : ThisBase(key, keyLength, salt, saltLength, personalization, personalizationLength, treeMode, digestSize) {} }; diff --git a/channels.cpp b/channels.cpp index 318efd70..62419fdd 100644 --- a/channels.cpp +++ b/channels.cpp @@ -239,7 +239,7 @@ byte * ChannelSwitch::ChannelCreatePutSpace(const std::string &channel, size_t & return target.ChannelCreatePutSpace(ch, size); } size = 0; - return NULL; + return NULLPTR; } size_t ChannelSwitch::ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking) @@ -261,7 +261,7 @@ size_t ChannelSwitch::ChannelPutModifiable2(const std::string &channel, byte *in void ChannelSwitch::AddDefaultRoute(BufferedTransformation &destination) { - m_defaultRoutes.push_back(DefaultRoute(&destination, value_ptr(NULL))); + m_defaultRoutes.push_back(DefaultRoute(&destination, value_ptr(NULLPTR))); } void ChannelSwitch::RemoveDefaultRoute(BufferedTransformation &destination) diff --git a/config.h b/config.h index f468262e..e3d244eb 100644 --- a/config.h +++ b/config.h @@ -885,6 +885,22 @@ NAMESPACE_END # define CRYPTOPP_CXX11_CONSTEXPR 1 #endif // constexpr compilers +// nullptr_t: MS at VS2010 (16.00); GCC at 4.6; Clang at 3.3; Intel 12.0; SunCC 12.4. +// Intel has upported the feature since at least ICPC 12.00 +#if (CRYPTOPP_MSC_VERSION >= 1600) +# define CRYPTOPP_CXX11_NULLPTR 1 +#elif (__INTEL_COMPILER >= 1200) +# define CRYPTOPP_CXX11_NULLPTR 1 +#elif defined(__clang__) +# if __has_feature(cxx_nullptr) +# define CRYPTOPP_CXX11_NULLPTR 1 +# endif +#elif (CRYPTOPP_GCC_VERSION >= 40600) +# define CRYPTOPP_CXX11_NULLPTR 1 +#elif (__SUNPRO_CC >= 0x5130) +# define CRYPTOPP_CXX11_NULLPTR 1 +#endif // nullptr_t compilers + // TODO: Emplacement, R-values and Move semantics // Needed because we are catching warnings with GCC and MSC @@ -920,6 +936,13 @@ NAMESPACE_END # define CRYPTOPP_CONSTANT(x) constexpr static int x; #endif +// Hack... C++11 nullptr_t type safety and analysis +#if defined(CRYPTOPP_CXX11_NULLPTR) && !defined(NULLPTR) +# define NULLPTR nullptr +#elif !defined(NULLPTR) +# define NULLPTR NULL +#endif // CRYPTOPP_CXX11_NULLPTR + // OK to comment the following out, but please report it so we can fix it. // C++17 value taken from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4567.pdf. #if (defined(__cplusplus) && (__cplusplus >= 199711L) && (__cplusplus < 201402L)) && !defined(CRYPTOPP_UNCAUGHT_EXCEPTION_AVAILABLE) diff --git a/cpu.cpp b/cpu.cpp index e4d3b7d4..a07b6be6 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -94,7 +94,7 @@ bool CpuId(word32 input, word32 output[4]) # ifndef __MINGW32__ volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; # endif @@ -118,7 +118,7 @@ bool CpuId(word32 input, word32 output[4]) } # ifndef __MINGW32__ - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); # endif signal(SIGILL, oldHandler); @@ -159,7 +159,7 @@ static bool TrySSE2() # ifndef __MINGW32__ volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; # endif @@ -176,7 +176,7 @@ static bool TrySSE2() } # ifndef __MINGW32__ - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); # endif signal(SIGILL, oldHandler); @@ -406,7 +406,7 @@ static bool TryNEON() return false; volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; if (setjmp(s_jmpNoNEON)) @@ -429,7 +429,7 @@ static bool TryNEON() result = !!(vgetq_lane_u32(x3,0) | vgetq_lane_u64(x4,1)); } - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); signal(SIGILL, oldHandler); return result; # endif @@ -474,7 +474,7 @@ static bool TryPMULL() return false; volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; if (setjmp(s_jmpNoPMULL)) @@ -496,7 +496,7 @@ static bool TryPMULL() vgetq_lane_u64(t2,0) == 0x6c006c006c006c00 && vgetq_lane_u64(t2,1) == 0x6c006c006c006c00); } - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); signal(SIGILL, oldHandler); return result; # endif @@ -534,7 +534,7 @@ static bool TryCRC32() return false; volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; if (setjmp(s_jmpNoCRC32)) @@ -550,7 +550,7 @@ static bool TryCRC32() result = !!w; } - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); signal(SIGILL, oldHandler); return result; # endif @@ -588,7 +588,7 @@ static bool TryAES() return false; volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; if (setjmp(s_jmpNoAES)) @@ -603,7 +603,7 @@ static bool TryAES() result = !!(vgetq_lane_u8(r1,0) | vgetq_lane_u8(r2,7)); } - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); signal(SIGILL, oldHandler); return result; # endif @@ -644,7 +644,7 @@ static bool TrySHA1() return false; volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; if (setjmp(s_jmpNoSHA1)) @@ -663,7 +663,7 @@ static bool TrySHA1() result = !!(vgetq_lane_u32(r1,0) | vgetq_lane_u32(r2,1) | vgetq_lane_u32(r3,2) | vgetq_lane_u32(r4,3) | vgetq_lane_u32(r5,0)); } - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); signal(SIGILL, oldHandler); return result; # endif @@ -703,7 +703,7 @@ static bool TrySHA2() return false; volatile sigset_t oldMask; - if (sigprocmask(0, NULL, (sigset_t*)&oldMask)) + if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask)) return false; if (setjmp(s_jmpNoSHA2)) @@ -721,7 +721,7 @@ static bool TrySHA2() result = !!(vgetq_lane_u32(r1,0) | vgetq_lane_u32(r2,1) | vgetq_lane_u32(r3,2) | vgetq_lane_u32(r4,3)); } - sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULL); + sigprocmask(SIG_SETMASK, (sigset_t*)&oldMask, NULLPTR); signal(SIGILL, oldHandler); return result; # endif diff --git a/cryptlib.cpp b/cryptlib.cpp index dc6e2b33..7942ea25 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -163,7 +163,7 @@ const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs { ThrowIfResynchronizable(); size = 0; - return NULL; + return NULLPTR; } } @@ -392,7 +392,7 @@ public: void Shuffle (IT begin, IT end) {} private: - Clonable* Clone () const { return NULL; } + Clonable* Clone () const { return NULLPTR; } #endif }; diff --git a/cryptlib.h b/cryptlib.h index 87d1a695..addf9c2c 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -698,8 +698,8 @@ protected: //! \brief Validates the IV //! \param iv the IV with a length of IVSize, in bytes //! \throws InvalidArgument on failure - //! \details Internally, the default implementation checks the iv. If iv is not NULL, - //! then the function succeeds. If iv is NULL, then IVRequirement is checked against + //! \details Internally, the default implementation checks the iv. If iv is not NULLPTR, + //! then the function succeeds. If iv is NULLPTR, then IVRequirement is checked against //! UNPREDICTABLE_RANDOM_IV. If IVRequirement is UNPREDICTABLE_RANDOM_IV, then //! then the function succeeds. Otherwise, an exception is thrown. void ThrowIfInvalidIV(const byte *iv); @@ -752,7 +752,7 @@ public: //! \sa FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize() //! \note The message can be transformed in-place, or the buffers must \a not overlap void ProcessBlock(const byte *inBlock, byte *outBlock) const - {ProcessAndXorBlock(inBlock, NULL, outBlock);} + {ProcessAndXorBlock(inBlock, NULLPTR, outBlock);} //! \brief Encrypt or decrypt a block in place //! \param inoutBlock the input message before processing @@ -761,7 +761,7 @@ public: //! Use BLOCKSIZE at compile time, or BlockSize() at runtime. //! \sa FixedBlockSize, BlockCipherFinal from seckey.h and BlockSize() void ProcessBlock(byte *inoutBlock) const - {ProcessAndXorBlock(inoutBlock, NULL, inoutBlock);} + {ProcessAndXorBlock(inoutBlock, NULLPTR, inoutBlock);} //! Provides the block size of the cipher //! \return the block size of the cipher, in bytes @@ -946,7 +946,7 @@ public: //! the array returned to the caller. //! \details The base class implementation sets size to 0 and returns NULL. //! \note Some objects, like ArraySink, cannot create a space because its fixed. - virtual byte * CreateUpdateSpace(size_t &size) {size=0; return NULL;} + virtual byte * CreateUpdateSpace(size_t &size) {size=0; return NULLPTR;} //! \brief Computes the hash of the current message //! \param digest a pointer to the buffer to receive the hash @@ -959,7 +959,7 @@ public: //! \brief Restart the hash //! \details Discards the current state, and restart for a new message virtual void Restart() - {TruncatedFinal(NULL, 0);} + {TruncatedFinal(NULLPTR, 0);} //! Provides the digest size of the hash //! \return the digest size of the hash. @@ -1385,11 +1385,11 @@ public: //! \details size is an \a IN and \a OUT parameter and used as a hint. When the call is made, //! size is the requested size of the buffer. When the call returns, size is the size of //! the array returned to the caller. - //! \details The base class implementation sets size to 0 and returns NULL. + //! \details The base class implementation sets size to 0 and returns NULL. //! \note Some objects, like ArraySink, cannot create a space because its fixed. In the case of //! an ArraySink, the pointer to the array is returned and the size is remaining size. virtual byte * CreatePutSpace(size_t &size) - {size=0; return NULL;} + {size=0; return NULLPTR;} //! \brief Determines whether input can be modified by the callee //! \return true if input can be modified, false otherwise @@ -1412,7 +1412,7 @@ public: //! \details propagation count includes this object. Setting propagation to 1 means this //! object only. Setting propagation to -1 means unlimited propagation. bool MessageEnd(int propagation=-1, bool blocking=true) - {return !!Put2(NULL, 0, propagation < 0 ? -1 : propagation+1, blocking);} + {return !!Put2(NULLPTR, 0, propagation < 0 ? -1 : propagation+1, blocking);} //! \brief Input multiple bytes for processing and signal the end of a message //! \param inString the byte buffer to process @@ -1882,7 +1882,7 @@ public: //! \details propagation count includes this object. Setting propagation to 1 means this //! object only. Setting propagation to -1 means unlimited propagation. bool ChannelMessageEnd(const std::string &channel, int propagation=-1, bool blocking=true) - {return !!ChannelPut2(channel, NULL, 0, propagation < 0 ? -1 : propagation+1, blocking);} + {return !!ChannelPut2(channel, NULLPTR, 0, propagation < 0 ? -1 : propagation+1, blocking);} //! \brief Input multiple bytes for processing and signal the end of a message //! \param channel the channel to process the data. @@ -1969,7 +1969,7 @@ public: //! \return the attached transformation //! \details AttachedTransformation() returns NULL if there is no attachment. The non-const //! version of AttachedTransformation() always returns NULL. - virtual BufferedTransformation *AttachedTransformation() {CRYPTOPP_ASSERT(!Attachable()); return 0;} + virtual BufferedTransformation *AttachedTransformation() {CRYPTOPP_ASSERT(!Attachable()); return NULLPTR;} //! \brief Returns the object immediately attached to this object //! \return the attached transformation @@ -1984,7 +1984,7 @@ public: //! \details Detach delete the current attachment chain and replace it with an optional newAttachment //! \details If a derived class does not override Detach, then the base class throws //! NotImplemented. - virtual void Detach(BufferedTransformation *newAttachment = 0) { + virtual void Detach(BufferedTransformation *newAttachment = NULLPTR) { CRYPTOPP_UNUSED(newAttachment); CRYPTOPP_ASSERT(!Attachable()); throw NotImplemented("BufferedTransformation: this object is not attachable"); } @@ -2330,7 +2330,7 @@ public: //! \details \p attachment can be \p NULL. The caller is responsible for deleting the returned pointer. //! Encoding parameters should be passed in the "EP" channel. virtual BufferedTransformation * CreateEncryptionFilter(RandomNumberGenerator &rng, - BufferedTransformation *attachment=NULL, const NameValuePairs ¶meters = g_nullNameValuePairs) const; + BufferedTransformation *attachment=NULLPTR, const NameValuePairs ¶meters = g_nullNameValuePairs) const; }; //! \class PK_Decryptor @@ -2365,7 +2365,7 @@ public: //! \return the newly created decryption filter //! \note the caller is responsible for deleting the returned pointer virtual BufferedTransformation * CreateDecryptionFilter(RandomNumberGenerator &rng, - BufferedTransformation *attachment=NULL, const NameValuePairs ¶meters = g_nullNameValuePairs) const; + BufferedTransformation *attachment=NULLPTR, const NameValuePairs ¶meters = g_nullNameValuePairs) const; //! \brief Decrypt a fixed size ciphertext //! \param rng a RandomNumberGenerator derived class @@ -2811,7 +2811,7 @@ public: virtual ~ProtocolSession() {} - ProtocolSession() : m_rng(NULL), m_throwOnProtocolError(true), m_validState(false) {} + ProtocolSession() : m_rng(NULLPTR), m_throwOnProtocolError(true), m_validState(false) {} virtual void InitializeSession(RandomNumberGenerator &rng, const NameValuePairs ¶meters) =0; diff --git a/datatest.cpp b/datatest.cpp index 00764729..90c6a1df 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -40,7 +40,7 @@ public: TestFailure() : Exception(OTHER_ERROR, "Validation test failed") {} }; -static const TestData *s_currentTestData = NULL; +static const TestData *s_currentTestData = NULLPTR; static void OutputTestData(const TestData &v) { @@ -251,7 +251,7 @@ void TestSignatureScheme(TestData &v) if (test == "Verify" || test == "NotVerify") { - SignatureVerificationFilter verifierFilter(*verifier, NULL, SignatureVerificationFilter::SIGNATURE_AT_BEGIN); + SignatureVerificationFilter verifierFilter(*verifier, NULLPTR, SignatureVerificationFilter::SIGNATURE_AT_BEGIN); PutDecodedDatumInto(v, "Signature", verifierFilter); PutDecodedDatumInto(v, "Message", verifierFilter); verifierFilter.MessageEnd(); @@ -275,7 +275,7 @@ void TestSignatureScheme(TestData &v) if (test == "GenerateKey" || test == "KeyPairValidAndConsistent") { TestKeyPairValidAndConsistent(verifier->AccessMaterial(), signer->GetMaterial()); - SignatureVerificationFilter verifierFilter(*verifier, NULL, SignatureVerificationFilter::THROW_EXCEPTION); + SignatureVerificationFilter verifierFilter(*verifier, NULLPTR, SignatureVerificationFilter::THROW_EXCEPTION); verifierFilter.Put((const byte *)"abc", 3); StringSource ss("abc", true, new SignerFilter(Test::GlobalRNG(), *signer, new Redirector(verifierFilter))); } @@ -579,7 +579,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest) member_ptr mac; member_ptr hash; - HashTransformation *pHash = NULL; + HashTransformation *pHash = NULLPTR; TestDataNameValuePairs pairs(v); @@ -601,7 +601,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest) int digestSize = -1; if (test == "VerifyTruncated") digestSize = pairs.GetIntValueWithDefault(Name::DigestSize(), digestSize); - HashVerificationFilter verifierFilter(*pHash, NULL, HashVerificationFilter::HASH_AT_BEGIN, digestSize); + HashVerificationFilter verifierFilter(*pHash, NULLPTR, HashVerificationFilter::HASH_AT_BEGIN, digestSize); PutDecodedDatumInto(v, digestName, verifierFilter); PutDecodedDatumInto(v, "Message", verifierFilter); verifierFilter.MessageEnd(); diff --git a/default.cpp b/default.cpp index 8cbdb7ac..8383499f 100644 --- a/default.cpp +++ b/default.cpp @@ -78,7 +78,7 @@ static void GenerateKeyIV(const byte *passphrase, size_t passphraseLength, const template DataEncryptor::DataEncryptor(const char *passphrase, BufferedTransformation *attachment) - : ProxyFilter(NULL, 0, 0, attachment), m_passphrase((const byte *)passphrase, strlen(passphrase)) + : ProxyFilter(NULLPTR, 0, 0, attachment), m_passphrase((const byte *)passphrase, strlen(passphrase)) { CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DIGESTSIZE); CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE <= DIGESTSIZE); @@ -86,7 +86,7 @@ DataEncryptor::DataEncryptor(const char *passphrase, BufferedTransfor template DataEncryptor::DataEncryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment) - : ProxyFilter(NULL, 0, 0, attachment), m_passphrase(passphrase, passphraseLength) + : ProxyFilter(NULLPTR, 0, 0, attachment), m_passphrase(passphrase, passphraseLength) { CRYPTOPP_COMPILE_ASSERT(SALTLENGTH <= DIGESTSIZE); CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE <= DIGESTSIZE); @@ -100,7 +100,7 @@ void DataEncryptor::FirstPut(const byte *) // use hash(passphrase | time | clock) as salt hash.Update(m_passphrase, m_passphrase.size()); - time_t t=time(0); + time_t t=time(NULLPTR); hash.Update((byte *)&t, sizeof(t)); clock_t c=clock(); hash.Update((byte *)&c, sizeof(c)); @@ -135,7 +135,7 @@ void DataEncryptor::LastPut(const byte *inString, size_t length) template DataDecryptor::DataDecryptor(const char *p, BufferedTransformation *attachment, bool throwException) - : ProxyFilter(NULL, SALTLENGTH+BLOCKSIZE, 0, attachment) + : ProxyFilter(NULLPTR, SALTLENGTH+BLOCKSIZE, 0, attachment) , m_state(WAITING_FOR_KEYCHECK) , m_passphrase((const byte *)p, strlen(p)) , m_throwException(throwException) @@ -146,7 +146,7 @@ DataDecryptor::DataDecryptor(const char *p, BufferedTransformation *a template DataDecryptor::DataDecryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException) - : ProxyFilter(NULL, SALTLENGTH+BLOCKSIZE, 0, attachment) + : ProxyFilter(NULLPTR, SALTLENGTH+BLOCKSIZE, 0, attachment) , m_state(WAITING_FOR_KEYCHECK) , m_passphrase(passphrase, passphraseLength) , m_throwException(throwException) @@ -165,7 +165,7 @@ template void DataDecryptor::LastPut(const byte *inString, size_t length) { CRYPTOPP_UNUSED(inString); CRYPTOPP_UNUSED(length); - if (m_filter.get() == NULL) + if (m_filter.get() == NULLPTR) { m_state = KEY_BAD; if (m_throwException) @@ -225,7 +225,7 @@ static MAC* NewDataEncryptorMAC(const byte *passphrase, size_t passphraseLength) template DataEncryptorWithMAC::DataEncryptorWithMAC(const char *passphrase, BufferedTransformation *attachment) - : ProxyFilter(NULL, 0, 0, attachment) + : ProxyFilter(NULLPTR, 0, 0, attachment) , m_mac(NewDataEncryptorMAC((const byte *)passphrase, strlen(passphrase))) { SetFilter(new HashFilter(*m_mac, new DataEncryptor(passphrase), true)); @@ -233,7 +233,7 @@ DataEncryptorWithMAC::DataEncryptorWithMAC(const char *passphrase template DataEncryptorWithMAC::DataEncryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment) - : ProxyFilter(NULL, 0, 0, attachment) + : ProxyFilter(NULLPTR, 0, 0, attachment) , m_mac(NewDataEncryptorMAC(passphrase, passphraseLength)) { SetFilter(new HashFilter(*m_mac, new DataEncryptor(passphrase, passphraseLength), true)); @@ -250,20 +250,20 @@ void DataEncryptorWithMAC::LastPut(const byte *inString, size_t l template DataDecryptorWithMAC::DataDecryptorWithMAC(const char *passphrase, BufferedTransformation *attachment, bool throwException) - : ProxyFilter(NULL, 0, 0, attachment) + : ProxyFilter(NULLPTR, 0, 0, attachment) , m_mac(NewDataEncryptorMAC((const byte *)passphrase, strlen(passphrase))) , m_throwException(throwException) { - SetFilter(new DataDecryptor(passphrase, m_hashVerifier=new HashVerificationFilter(*m_mac, NULL, HashVerificationFilter::PUT_MESSAGE), throwException)); + SetFilter(new DataDecryptor(passphrase, m_hashVerifier=new HashVerificationFilter(*m_mac, NULLPTR, HashVerificationFilter::PUT_MESSAGE), throwException)); } template DataDecryptorWithMAC::DataDecryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment, bool throwException) - : ProxyFilter(NULL, 0, 0, attachment) + : ProxyFilter(NULLPTR, 0, 0, attachment) , m_mac(NewDataEncryptorMAC(passphrase, passphraseLength)) , m_throwException(throwException) { - SetFilter(new DataDecryptor(passphrase, passphraseLength, m_hashVerifier=new HashVerificationFilter(*m_mac, NULL, HashVerificationFilter::PUT_MESSAGE), throwException)); + SetFilter(new DataDecryptor(passphrase, passphraseLength, m_hashVerifier=new HashVerificationFilter(*m_mac, NULLPTR, HashVerificationFilter::PUT_MESSAGE), throwException)); } template diff --git a/default.h b/default.h index 9dd20d08..78bc0d19 100644 --- a/default.h +++ b/default.h @@ -92,13 +92,13 @@ public: //! \brief Construct a DataEncryptor //! \param passphrase a C-String password //! \param attachment a BufferedTransformation to attach to this object - DataEncryptor(const char *passphrase, BufferedTransformation *attachment = NULL); + DataEncryptor(const char *passphrase, BufferedTransformation *attachment = NULLPTR); //! \brief Construct a DataEncryptor //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object - DataEncryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULL); + DataEncryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR); protected: void FirstPut(const byte *); @@ -132,14 +132,14 @@ public: //! \param passphrase a C-String password //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error - DataDecryptor(const char *passphrase, BufferedTransformation *attachment = NULL, bool throwException=true); + DataDecryptor(const char *passphrase, BufferedTransformation *attachment = NULLPTR, bool throwException=true); //! \brief Constructs a DataDecryptor //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error - DataDecryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULL, bool throwException=true); + DataDecryptor(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR, bool throwException=true); enum State {WAITING_FOR_KEYCHECK, KEY_GOOD, KEY_BAD}; State CurrentState() const {return m_state;} @@ -183,13 +183,13 @@ public: //! \brief Constructs a DataEncryptorWithMAC //! \param passphrase a C-String password //! \param attachment a BufferedTransformation to attach to this object - DataEncryptorWithMAC(const char *passphrase, BufferedTransformation *attachment = NULL); + DataEncryptorWithMAC(const char *passphrase, BufferedTransformation *attachment = NULLPTR); //! \brief Constructs a DataEncryptorWithMAC //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object - DataEncryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULL); + DataEncryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR); protected: void FirstPut(const byte *inString) {CRYPTOPP_UNUSED(inString);} @@ -224,14 +224,14 @@ public: //! \param passphrase a C-String password //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error - DataDecryptorWithMAC(const char *passphrase, BufferedTransformation *attachment = NULL, bool throwException=true); + DataDecryptorWithMAC(const char *passphrase, BufferedTransformation *attachment = NULLPTR, bool throwException=true); //! \brief Constructs a DataDecryptor //! \param passphrase a byte string password //! \param passphraseLength the length of the byte string password //! \param attachment a BufferedTransformation to attach to this object //! \param throwException a flag specifiying whether an Exception should be thrown on error - DataDecryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULL, bool throwException=true); + DataDecryptorWithMAC(const byte *passphrase, size_t passphraseLength, BufferedTransformation *attachment = NULLPTR, bool throwException=true); typename DataDecryptor::State CurrentState() const; bool CheckLastMAC() const; diff --git a/dh2.cpp b/dh2.cpp index 08378366..40e6dd50 100644 --- a/dh2.cpp +++ b/dh2.cpp @@ -8,7 +8,7 @@ NAMESPACE_BEGIN(CryptoPP) #if defined(CRYPTOPP_DEBUG) && !defined(CRYPTOPP_DOXYGEN_PROCESSING) void DH2_TestInstantiations() { - DH2 dh(*(SimpleKeyAgreementDomain*)NULL); + DH2 dh(*(SimpleKeyAgreementDomain*)NULLPTR); } #endif diff --git a/dll.cpp b/dll.cpp index c7bfdc51..7b57dc1f 100644 --- a/dll.cpp +++ b/dll.cpp @@ -58,13 +58,13 @@ USING_NAMESPACE(CryptoPP) using std::set_new_handler; -static PNew s_pNew = NULL; -static PDelete s_pDelete = NULL; +static PNew s_pNew = NULLPTR; +static PDelete s_pDelete = NULLPTR; static void * New (size_t size) { void *p; - while ((p = malloc(size)) == NULL) + while ((p = malloc(size)) == NULLPTR) CallNewHandler(); return p; @@ -75,8 +75,8 @@ static void * New (size_t size) static void SetNewAndDeleteFunctionPointers() { - void *p = NULL; - HMODULE hModule = NULL; + void *p = NULLPTR; + HMODULE hModule = NULLPTR; MEMORY_BASIC_INFORMATION mbi; while (true) diff --git a/dlltest.cpp b/dlltest.cpp index 6b6ed332..27def6f0 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -175,8 +175,8 @@ void FIPS140_SampleApplication() #ifdef CRYPTOPP_IMPORTS -static PNew s_pNew = NULL; -static PDelete s_pDelete = NULL; +static PNew s_pNew = NULLPTR; +static PDelete s_pDelete = NULLPTR; extern "C" __declspec(dllexport) void __cdecl SetNewAndDeleteFromCryptoPP(PNew pNew, PDelete pDelete, PSetNewHandler pSetNewHandler) { diff --git a/drbg.h b/drbg.h index 1a2c5184..35358e41 100644 --- a/drbg.h +++ b/drbg.h @@ -195,8 +195,8 @@ public: //! Hash_DRBG drbg(entropy, 32, entropy+32, 16); //! drbg.GenerateBlock(result, result.size()); //! - Hash_DRBG(const byte* entropy, size_t entropyLength=STRENGTH, const byte* nonce=NULL, - size_t nonceLength=0, const byte* personalization=NULL, size_t personalizationLength=0) + Hash_DRBG(const byte* entropy, size_t entropyLength=STRENGTH, const byte* nonce=NULLPTR, + size_t nonceLength=0, const byte* personalization=NULLPTR, size_t personalizationLength=0) : NIST_DRBG(), m_c(SEEDLENGTH), m_v(SEEDLENGTH) { DRBG_Instantiate(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); @@ -212,13 +212,13 @@ public: unsigned int GetMaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} void IncorporateEntropy(const byte *input, size_t length) - {return DRBG_Reseed(input, length, NULL, 0);} + {return DRBG_Reseed(input, length, NULLPTR, 0);} void IncorporateEntropy(const byte *entropy, size_t entropyLength, const byte* additional, size_t additionaLength) {return DRBG_Reseed(entropy, entropyLength, additional, additionaLength);} void GenerateBlock(byte *output, size_t size) - {return Hash_Generate(NULL, 0, output, size);} + {return Hash_Generate(NULLPTR, 0, output, size);} void GenerateBlock(const byte* additional, size_t additionaLength, byte *output, size_t size) {return Hash_Generate(additional, additionaLength, output, size);} @@ -306,8 +306,8 @@ public: //! HMAC_DRBG drbg(entropy, 32, entropy+32, 16); //! drbg.GenerateBlock(result, result.size()); //! - HMAC_DRBG(const byte* entropy, size_t entropyLength=STRENGTH, const byte* nonce=NULL, - size_t nonceLength=0, const byte* personalization=NULL, size_t personalizationLength=0) + HMAC_DRBG(const byte* entropy, size_t entropyLength=STRENGTH, const byte* nonce=NULLPTR, + size_t nonceLength=0, const byte* personalization=NULLPTR, size_t personalizationLength=0) : NIST_DRBG(), m_k(HASH::DIGESTSIZE), m_v(HASH::DIGESTSIZE) { DRBG_Instantiate(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); @@ -323,13 +323,13 @@ public: unsigned int GetMaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} void IncorporateEntropy(const byte *input, size_t length) - {return DRBG_Reseed(input, length, NULL, 0);} + {return DRBG_Reseed(input, length, NULLPTR, 0);} void IncorporateEntropy(const byte *entropy, size_t entropyLength, const byte* additional, size_t additionaLength) {return DRBG_Reseed(entropy, entropyLength, additional, additionaLength);} void GenerateBlock(byte *output, size_t size) - {return HMAC_Generate(NULL, 0, output, size);} + {return HMAC_Generate(NULLPTR, 0, output, size);} void GenerateBlock(const byte* additional, size_t additionaLength, byte *output, size_t size) {return HMAC_Generate(additional, additionaLength, output, size);} @@ -382,8 +382,8 @@ void Hash_DRBG::DRBG_Instantiate(const byte* entropy const byte zero = 0; SecByteBlock t1(SEEDLENGTH), t2(SEEDLENGTH); - Hash_Update(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength, NULL, 0, t1, t1.size()); - Hash_Update(&zero, 1, t1, t1.size(), NULL, 0, NULL, 0, t2, t2.size()); + Hash_Update(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength, NULLPTR, 0, t1, t1.size()); + Hash_Update(&zero, 1, t1, t1.size(), NULLPTR, 0, NULLPTR, 0, t2, t2.size()); m_v.swap(t1); m_c.swap(t2); m_reseed = 1; @@ -410,7 +410,7 @@ void Hash_DRBG::DRBG_Reseed(const byte* entropy, siz const byte zero = 0, one = 1; SecByteBlock t1(SEEDLENGTH), t2(SEEDLENGTH); Hash_Update(&one, 1, m_v, m_v.size(), entropy, entropyLength, additional, additionaLength, t1, t1.size()); - Hash_Update(&zero, 1, t1, t1.size(), NULL, 0, NULL, 0, t2, t2.size()); + Hash_Update(&zero, 1, t1, t1.size(), NULLPTR, 0, NULLPTR, 0, t2, t2.size()); m_v.swap(t1); m_c.swap(t2); m_reseed = 1; @@ -589,7 +589,7 @@ void HMAC_DRBG::DRBG_Reseed(const byte* entropy, siz CRYPTOPP_ASSERT(entropyLength <= MAXIMUM_ENTROPY); CRYPTOPP_ASSERT(additionaLength <= MAXIMUM_ADDITIONAL); - HMAC_Update(entropy, entropyLength, additional, additionaLength, NULL, 0); + HMAC_Update(entropy, entropyLength, additional, additionaLength, NULLPTR, 0); m_reseed = 1; } @@ -610,7 +610,7 @@ void HMAC_DRBG::HMAC_Generate(const byte* additional // Step 2 if (additional && additionaLength) - HMAC_Update(additional, additionaLength, NULL, 0, NULL, 0); + HMAC_Update(additional, additionaLength, NULLPTR, 0, NULLPTR, 0); // Step 3 HMAC hmac; @@ -627,7 +627,7 @@ void HMAC_DRBG::HMAC_Generate(const byte* additional size -= count; output += count; } - HMAC_Update(additional, additionaLength, NULL, 0, NULL, 0); + HMAC_Update(additional, additionaLength, NULLPTR, 0, NULLPTR, 0); m_reseed++; } diff --git a/eccrypto.h b/eccrypto.h index faa5509c..df1dbe81 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -117,7 +117,7 @@ public: Point result; if (!GetCurve().DecodePoint(result, encoded, GetEncodedElementSize(true))) throw DL_BadElement(); - if (checkForGroupMembership && !ValidateElement(1, result, NULL)) + if (checkForGroupMembership && !ValidateElement(1, result, NULLPTR)) throw DL_BadElement(); return result; } @@ -526,7 +526,7 @@ public: virtual void AssignFrom(const NameValuePairs &source) { - DL_PrivateKey_ECGDSA_ISO15946 *pPrivateKey = NULL; + DL_PrivateKey_ECGDSA_ISO15946 *pPrivateKey = NULLPTR; if (source.GetThisPointer(pPrivateKey)) pPrivateKey->MakePublicKey(*this); else diff --git a/factory.h b/factory.h index c3aa9163..df69f0bb 100644 --- a/factory.h +++ b/factory.h @@ -56,7 +56,7 @@ public: for (typename Map::iterator i = m_map.begin(); i != m_map.end(); ++i) { delete (ObjectFactory *)i->second; - i->second = NULL; + i->second = NULLPTR; } } @@ -68,7 +68,7 @@ public: const ObjectFactory * GetFactory(const char *name) const { typename Map::const_iterator i = m_map.find(name); - return i == m_map.end() ? NULL : (ObjectFactory *)i->second; + return i == m_map.end() ? NULLPTR : (ObjectFactory *)i->second; } AbstractClass *CreateObject(const char *name) const @@ -113,7 +113,7 @@ ObjectFactoryRegistry & ObjectFactoryRegistry struct RegisterDefaultFactoryFor { - RegisterDefaultFactoryFor(const char *name=NULL) + RegisterDefaultFactoryFor(const char *name=NULLPTR) { // BCB2006 workaround std::string n = name ? std::string(name) : std::string(ConcreteClass::StaticAlgorithmName()); @@ -130,7 +130,7 @@ struct RegisterDefaultFactoryFor //! symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), //! authenticated symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), etc. template -void RegisterAsymmetricCipherDefaultFactories(const char *name=NULL) +void RegisterAsymmetricCipherDefaultFactories(const char *name=NULLPTR) { RegisterDefaultFactoryFor((const char *)name); RegisterDefaultFactoryFor((const char *)name); @@ -144,7 +144,7 @@ void RegisterAsymmetricCipherDefaultFactories(const char *name=NULL) //! symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), //! authenticated symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), etc. template -void RegisterSignatureSchemeDefaultFactories(const char *name=NULL) +void RegisterSignatureSchemeDefaultFactories(const char *name=NULLPTR) { RegisterDefaultFactoryFor((const char *)name); RegisterDefaultFactoryFor((const char *)name); @@ -158,7 +158,7 @@ void RegisterSignatureSchemeDefaultFactories(const char *name=NULL) //! symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), //! authenticated symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), etc. template -void RegisterSymmetricCipherDefaultFactories(const char *name=NULL) +void RegisterSymmetricCipherDefaultFactories(const char *name=NULLPTR) { RegisterDefaultFactoryFor((const char *)name); RegisterDefaultFactoryFor((const char *)name); @@ -172,7 +172,7 @@ void RegisterSymmetricCipherDefaultFactories(const char *name=NULL) //! symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), //! authenticated symmetric ciphers (registers SchemeClass::Encryptor and SchemeClass::Decryptor), etc. template -void RegisterAuthenticatedSymmetricCipherDefaultFactories(const char *name=NULL) +void RegisterAuthenticatedSymmetricCipherDefaultFactories(const char *name=NULLPTR) { RegisterDefaultFactoryFor((const char *)name); RegisterDefaultFactoryFor((const char *)name); diff --git a/fhmqv.h b/fhmqv.h index 2d011200..49120f02 100644 --- a/fhmqv.h +++ b/fhmqv.h @@ -126,7 +126,7 @@ public: const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { - byte *XX = NULL, *YY = NULL, *AA = NULL, *BB = NULL; + byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; size_t xxs = 0, yys = 0, aas = 0, bbs = 0; // Depending on the role, this will hold either A's or B's static @@ -177,13 +177,13 @@ public: // VerifyPoint to ensure the element is in G*. If the other's PublicKey is // requested to be validated, we manually call ValidateElement at level 3. Element VV1 = params.DecodeElement(staticOtherPublicKey, false); - if(!params.ValidateElement(validateStaticOtherPublicKey ? 3 : 1, VV1, NULL)) + if(!params.ValidateElement(validateStaticOtherPublicKey ? 3 : 1, VV1, NULLPTR)) return false; // DecodeElement calls ValidateElement at level 1. Level 1 only calls // VerifyPoint to ensure the element is in G*. Crank it up. Element VV2 = params.DecodeElement(ephemeralOtherPublicKey, false); - if(!params.ValidateElement(3, VV2, NULL)) + if(!params.ValidateElement(3, VV2, NULLPTR)) return false; const Integer& q = params.GetSubgroupOrder(); @@ -192,10 +192,10 @@ public: Integer d, e; SecByteBlock dd(len), ee(len); - Hash(NULL, XX, xxs, YY, yys, AA, aas, BB, bbs, dd.BytePtr(), dd.SizeInBytes()); + Hash(NULLPTR, XX, xxs, YY, yys, AA, aas, BB, bbs, dd.BytePtr(), dd.SizeInBytes()); d.Decode(dd.BytePtr(), dd.SizeInBytes()); - Hash(NULL, YY, yys, XX, xxs, AA, aas, BB, bbs, ee.BytePtr(), ee.SizeInBytes()); + Hash(NULLPTR, YY, yys, XX, xxs, AA, aas, BB, bbs, ee.BytePtr(), ee.SizeInBytes()); e.Decode(ee.BytePtr(), ee.SizeInBytes()); Element sigma; diff --git a/files.cpp b/files.cpp index 6c0d1f13..c200e9e7 100644 --- a/files.cpp +++ b/files.cpp @@ -22,12 +22,12 @@ void Files_TestInstantiations() void FileStore::StoreInitialize(const NameValuePairs ¶meters) { m_waiting = false; - m_stream = NULL; + m_stream = NULLPTR; m_file.release(); - const char *fileName = NULL; + const char *fileName = NULLPTR; #if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 - const wchar_t *fileNameWide = NULL; + const wchar_t *fileNameWide = NULLPTR; if (!parameters.GetValue(Name::InputFileNameWide(), fileNameWide)) #endif if (!parameters.GetValue(Name::InputFileName(), fileName)) @@ -178,12 +178,12 @@ lword FileStore::Skip(lword skipMax) void FileSink::IsolatedInitialize(const NameValuePairs ¶meters) { - m_stream = NULL; + m_stream = NULLPTR; m_file.release(); - const char *fileName = NULL; + const char *fileName = NULLPTR; #if defined(CRYPTOPP_UNIX_AVAILABLE) || _MSC_VER >= 1400 - const wchar_t *fileNameWide = NULL; + const wchar_t *fileNameWide = NULLPTR; if (!parameters.GetValue(Name::OutputFileNameWide(), fileNameWide)) #endif if (!parameters.GetValue(Name::OutputFileName(), fileName)) diff --git a/files.h b/files.h index 1235b2e5..9670a19e 100644 --- a/files.h +++ b/files.h @@ -35,16 +35,16 @@ public: class ReadErr : public Err {public: ReadErr() : Err("FileStore: error reading file") {}}; //! \brief Construct a FileStore - FileStore() : m_stream(NULL), m_space(NULL), m_len(0), m_waiting(0) {} + FileStore() : m_stream(NULLPTR), m_space(NULLPTR), m_len(0), m_waiting(0) {} //! \brief Construct a FileStore //! \param in an existing stream - FileStore(std::istream &in) : m_stream(NULL), m_space(NULL), m_len(0), m_waiting(0) + FileStore(std::istream &in) : m_stream(NULLPTR), m_space(NULLPTR), m_len(0), m_waiting(0) {StoreInitialize(MakeParameters(Name::InputStreamPointer(), &in));} //! \brief Construct a FileStore //! \param filename the narrow name of the file to open - FileStore(const char *filename) : m_stream(NULL), m_space(NULL), m_len(0), m_waiting(0) + FileStore(const char *filename) : m_stream(NULLPTR), m_space(NULLPTR), m_len(0), m_waiting(0) {StoreInitialize(MakeParameters(Name::InputFileName(), filename ? filename : ""));} #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) || _MSC_VER >= 1400 @@ -85,14 +85,14 @@ public: typedef FileStore::ReadErr ReadErr; //! \brief Construct a FileSource - FileSource(BufferedTransformation *attachment = NULL) + FileSource(BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {} //! \brief Construct a FileSource //! \param in an existing stream //! \param pumpAll flag indicating if source data should be pumped to its attached transformation //! \param attachment an optional attached transformation - FileSource(std::istream &in, bool pumpAll, BufferedTransformation *attachment = NULL) + FileSource(std::istream &in, bool pumpAll, BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters(Name::InputStreamPointer(), &in));} //! \brief Construct a FileSource @@ -100,7 +100,7 @@ public: //! \param pumpAll flag indicating if source data should be pumped to its attached transformation //! \param attachment an optional attached transformation //! \param binary flag indicating if the file is binary - FileSource(const char *filename, bool pumpAll, BufferedTransformation *attachment = NULL, bool binary=true) + FileSource(const char *filename, bool pumpAll, BufferedTransformation *attachment = NULLPTR, bool binary=true) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters(Name::InputFileName(), filename)(Name::InputBinaryMode(), binary));} #if defined(CRYPTOPP_UNIX_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING) || _MSC_VER >= 1400 @@ -110,7 +110,7 @@ public: //! \param attachment an optional attached transformation //! \param binary flag indicating if the file is binary //! \details On non-Windows OS, this function assumes that setlocale() has been called. - FileSource(const wchar_t *filename, bool pumpAll, BufferedTransformation *attachment = NULL, bool binary=true) + FileSource(const wchar_t *filename, bool pumpAll, BufferedTransformation *attachment = NULLPTR, bool binary=true) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters(Name::InputFileNameWide(), filename)(Name::InputBinaryMode(), binary));} #endif @@ -137,7 +137,7 @@ public: class WriteErr : public Err {public: WriteErr() : Err("FileSink: error writing file") {}}; //! \brief Construct a FileSink - FileSink() : m_stream(NULL) {} + FileSink() : m_stream(NULLPTR) {} //! \brief Construct a FileSink //! \param out an existing stream diff --git a/filters.cpp b/filters.cpp index dcc65f5d..ca85edc7 100644 --- a/filters.cpp +++ b/filters.cpp @@ -35,14 +35,14 @@ BufferedTransformation * Filter::NewDefaultAttachment() const BufferedTransformation * Filter::AttachedTransformation() { - if (m_attachment.get() == NULL) + if (m_attachment.get() == NULLPTR) m_attachment.reset(NewDefaultAttachment()); return m_attachment.get(); } const BufferedTransformation *Filter::AttachedTransformation() const { - if (m_attachment.get() == NULL) + if (m_attachment.get() == NULLPTR) const_cast(this)->m_attachment.reset(NewDefaultAttachment()); return m_attachment.get(); } @@ -270,7 +270,7 @@ byte *FilterWithBufferedInput::BlockQueue::GetBlock() return ptr; } else - return NULL; + return NULLPTR; } byte *FilterWithBufferedInput::BlockQueue::GetContigousBlocks(size_t &numberOfBytes) @@ -423,7 +423,7 @@ size_t FilterWithBufferedInput::PutMaybeModifiable(byte *inString, size_t length if (messageEnd) { if (!m_firstInputDone && m_firstSize==0) - FirstPut(NULL); + FirstPut(NULLPTR); SecByteBlock temp(m_queue.CurrentSize()); m_queue.GetAll(temp); @@ -433,7 +433,7 @@ size_t FilterWithBufferedInput::PutMaybeModifiable(byte *inString, size_t length m_queue.ResetQueue(1, m_firstSize); // Cast to void to suppress Coverity finding - (void)Output(1, NULL, 0, messageEnd, blocking); + (void)Output(1, NULLPTR, 0, messageEnd, blocking); } return 0; } @@ -472,7 +472,7 @@ void FilterWithBufferedInput::NextPutMultiple(const byte *inString, size_t lengt void Redirector::Initialize(const NameValuePairs ¶meters, int propagation) { - m_target = parameters.GetValueWithDefault("RedirectionTargetPointer", (BufferedTransformation*)NULL); + m_target = parameters.GetValueWithDefault("RedirectionTargetPointer", (BufferedTransformation*)NULLPTR); m_behavior = parameters.GetIntValueWithDefault("RedirectionBehavior", PASS_EVERYTHING); if (m_target && GetPassSignals()) @@ -585,7 +585,7 @@ StreamTransformationFilter::StreamTransformationFilter(StreamTransformation &c, { CRYPTOPP_ASSERT(c.MinLastBlockSize() == 0 || c.MinLastBlockSize() > c.MandatoryBlockSize()); - if (!allowAuthenticatedSymmetricCipher && dynamic_cast(&c) != 0) + if (!allowAuthenticatedSymmetricCipher && dynamic_cast(&c) != NULLPTR) throw InvalidArgument("StreamTransformationFilter: please use AuthenticatedEncryptionFilter and AuthenticatedDecryptionFilter for AuthenticatedSymmetricCipher"); IsolatedInitialize(MakeParameters(Name::BlockPaddingScheme(), padding)); @@ -661,7 +661,7 @@ void StreamTransformationFilter::NextPutModifiable(byte *inString, size_t length void StreamTransformationFilter::LastPut(const byte *inString, size_t length) { - byte *space = NULL; + byte *space = NULLPTR; switch (m_padding) { @@ -768,7 +768,7 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length) // ************************************************************* HashFilter::HashFilter(HashTransformation &hm, BufferedTransformation *attachment, bool putMessage, int truncatedDigestSize, const std::string &messagePutChannel, const std::string &hashPutChannel) - : m_hashModule(hm), m_putMessage(putMessage), m_digestSize(0), m_space(NULL) + : m_hashModule(hm), m_putMessage(putMessage), m_digestSize(0), m_space(NULLPTR) , m_messagePutChannel(messagePutChannel), m_hashPutChannel(hashPutChannel) { m_digestSize = truncatedDigestSize < 0 ? m_hashModule.DigestSize() : truncatedDigestSize; diff --git a/filters.h b/filters.h index 05d03004..faa7b7dd 100644 --- a/filters.h +++ b/filters.h @@ -44,7 +44,7 @@ public: //! \brief Construct a Filter //! \param attachment an optional attached transformation //! \details attachment can be \p NULL. - Filter(BufferedTransformation *attachment = NULL); + Filter(BufferedTransformation *attachment = NULLPTR); //! \brief Determine if attachable //! \returns \p true if the object allows attached transformations, \p false otherwise. @@ -63,7 +63,7 @@ public: //! \param newAttachment an optional attached transformation //! \details newAttachment can be a single filter, a chain of filters or \p NULL. //! Pass \p NULL to remove an existing BufferedTransformation or chain of filters - void Detach(BufferedTransformation *newAttachment = NULL); + void Detach(BufferedTransformation *newAttachment = NULLPTR); //@} @@ -227,10 +227,10 @@ public: //! \param transparent flag indicating if the filter should function transparently //! \details \p attachment can be \p NULL. The filter is transparent by default. If the filter is //! transparent, then PutMaybeModifiable() does not process a request and always returns 0. - MeterFilter(BufferedTransformation *attachment=NULL, bool transparent=true) + MeterFilter(BufferedTransformation *attachment=NULLPTR, bool transparent=true) : m_transparent(transparent), m_currentMessageBytes(0), m_totalBytes(0) , m_currentSeriesMessages(0), m_totalMessages(0), m_totalMessageSeries(0) - , m_begin(NULL), m_length(0) {Detach(attachment); ResetMeter();} + , m_begin(NULLPTR), m_length(0) {Detach(attachment); ResetMeter();} //! \brief Set or change the transparent mode of this object //! \param transparent the new transparent mode @@ -293,7 +293,7 @@ class CRYPTOPP_DLL TransparentFilter : public MeterFilter public: //! \brief Construct a TransparentFilter //! \param attachment an optional attached transformation - TransparentFilter(BufferedTransformation *attachment=NULL) : MeterFilter(attachment, true) {} + TransparentFilter(BufferedTransformation *attachment=NULLPTR) : MeterFilter(attachment, true) {} }; //! \class OpaqueFilter @@ -304,7 +304,7 @@ class CRYPTOPP_DLL OpaqueFilter : public MeterFilter public: //! \brief Construct an OpaqueFilter //! \param attachment an optional attached transformation - OpaqueFilter(BufferedTransformation *attachment=NULL) : MeterFilter(attachment, false) {} + OpaqueFilter(BufferedTransformation *attachment=NULLPTR) : MeterFilter(attachment, false) {} }; //! \class FilterWithBufferedInput @@ -436,7 +436,7 @@ public: //! \brief Construct a FilterWithInputQueue //! \param attachment an optional attached transformation - FilterWithInputQueue(BufferedTransformation *attachment=NULL) : Filter(attachment) {} + FilterWithInputQueue(BufferedTransformation *attachment=NULLPTR) : Filter(attachment) {} size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) { @@ -447,7 +447,7 @@ public: if (messageEnd) { IsolatedMessageEnd(blocking); - Output(0, NULL, 0, messageEnd, blocking); + Output(0, NULLPTR, 0, messageEnd, blocking); } return 0; } @@ -511,7 +511,7 @@ public: //! \param attachment an optional attached transformation //! \param padding the \ref BlockPaddingSchemeDef "padding scheme" //! \param allowAuthenticatedSymmetricCipher flag indicating whether the filter should allow authenticated encryption schemes - StreamTransformationFilter(StreamTransformation &c, BufferedTransformation *attachment = NULL, BlockPaddingScheme padding = DEFAULT_PADDING, bool allowAuthenticatedSymmetricCipher = false); + StreamTransformationFilter(StreamTransformation &c, BufferedTransformation *attachment = NULLPTR, BlockPaddingScheme padding = DEFAULT_PADDING, bool allowAuthenticatedSymmetricCipher = false); std::string AlgorithmName() const {return m_cipher.AlgorithmName();} @@ -544,7 +544,7 @@ public: //! \param truncatedDigestSize the size of the digest //! \param messagePutChannel the channel on which the message should be output //! \param hashPutChannel the channel on which the digest should be output - HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL); + HashFilter(HashTransformation &hm, BufferedTransformation *attachment = NULLPTR, bool putMessage=false, int truncatedDigestSize=-1, const std::string &messagePutChannel=DEFAULT_CHANNEL, const std::string &hashPutChannel=DEFAULT_CHANNEL); std::string AlgorithmName() const {return m_hashModule.AlgorithmName();} void IsolatedInitialize(const NameValuePairs ¶meters); @@ -602,7 +602,7 @@ public: //! \param flags flags indicating behaviors for the filter //! \param truncatedDigestSize the size of the digest //! \details truncatedDigestSize = -1 indicates \ref HashTransformation::DigestSize() "DigestSize" should be used. - HashVerificationFilter(HashTransformation &hm, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1); + HashVerificationFilter(HashTransformation &hm, BufferedTransformation *attachment = NULLPTR, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1); std::string AlgorithmName() const {return m_hashModule.AlgorithmName();} bool GetLastResult() const {return m_verified;} @@ -643,7 +643,7 @@ public: //! \param padding the \ref BlockPaddingSchemeDef "padding scheme" //! \details truncatedDigestSize = -1 indicates \ref HashTransformation::DigestSize() "DigestSize" should be used. //! \since Crypto++ 5.6.0 - AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding = DEFAULT_PADDING); + AuthenticatedEncryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULLPTR, bool putAAD=false, int truncatedDigestSize=-1, const std::string &macChannel=DEFAULT_CHANNEL, BlockPaddingScheme padding = DEFAULT_PADDING); void IsolatedInitialize(const NameValuePairs ¶meters); byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); @@ -699,7 +699,7 @@ public: //! \details Additional authenticated data should be given in channel "AAD". //! \details truncatedDigestSize = -1 indicates \ref HashTransformation::DigestSize() "DigestSize" should be used. //! \since Crypto++ 5.6.0 - AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding = DEFAULT_PADDING); + AuthenticatedDecryptionFilter(AuthenticatedSymmetricCipher &c, BufferedTransformation *attachment = NULLPTR, word32 flags = DEFAULT_FLAGS, int truncatedDigestSize=-1, BlockPaddingScheme padding = DEFAULT_PADDING); std::string AlgorithmName() const {return m_hashVerifier.AlgorithmName();} byte * ChannelCreatePutSpace(const std::string &channel, size_t &size); @@ -740,7 +740,7 @@ public: //! \param signer a PK_Signer derived class //! \param attachment an optional attached transformation //! \param putMessage flag indicating whether the original message should be passed to an attached transformation - SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULL, bool putMessage=false) + SignerFilter(RandomNumberGenerator &rng, const PK_Signer &signer, BufferedTransformation *attachment = NULLPTR, bool putMessage=false) : m_rng(rng), m_signer(signer), m_messageAccumulator(signer.NewSignatureAccumulator(rng)), m_putMessage(putMessage) {Detach(attachment);} std::string AlgorithmName() const {return m_signer.AlgorithmName();} @@ -797,7 +797,7 @@ public: //! \param verifier a PK_Verifier derived class //! \param attachment an optional attached transformation //! \param flags flags indicating behaviors for the filter - SignatureVerificationFilter(const PK_Verifier &verifier, BufferedTransformation *attachment = NULL, word32 flags = DEFAULT_FLAGS); + SignatureVerificationFilter(const PK_Verifier &verifier, BufferedTransformation *attachment = NULLPTR, word32 flags = DEFAULT_FLAGS); std::string AlgorithmName() const {return m_verifier.AlgorithmName();} @@ -843,7 +843,7 @@ public: virtual ~Redirector() {} //! \brief Construct a Redirector - Redirector() : m_target(NULL), m_behavior(PASS_EVERYTHING) {} + Redirector() : m_target(NULLPTR), m_behavior(PASS_EVERYTHING) {} //! \brief Construct a Redirector //! \param target the destination BufferedTransformation @@ -855,7 +855,7 @@ public: //! \param target the destination BufferedTransformation void Redirect(BufferedTransformation &target) {m_target = ⌖} //! \brief Stop redirecting input - void StopRedirection() {m_target = NULL;} + void StopRedirection() {m_target = NULLPTR;} Behavior GetBehavior() {return (Behavior) m_behavior;} void SetBehavior(Behavior behavior) {m_behavior=behavior;} @@ -875,7 +875,7 @@ public: else { size = 0; - return NULL; + return NULLPTR; } } size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking) @@ -892,7 +892,7 @@ public: else { size = 0; - return NULL; + return NULLPTR; } } size_t ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking) @@ -1032,7 +1032,7 @@ public: //! \param rng a RandomNumberGenerator derived class //! \param encryptor a PK_Encryptor derived class //! \param attachment an optional attached transformation - PK_EncryptorFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment = NULL) + PK_EncryptorFilter(RandomNumberGenerator &rng, const PK_Encryptor &encryptor, BufferedTransformation *attachment = NULLPTR) : SimpleProxyFilter(encryptor.CreateEncryptionFilter(rng), attachment) {} }; @@ -1048,7 +1048,7 @@ public: //! \param rng a RandomNumberGenerator derived class //! \param decryptor a PK_Decryptor derived class //! \param attachment an optional attached transformation - PK_DecryptorFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment = NULL) + PK_DecryptorFilter(RandomNumberGenerator &rng, const PK_Decryptor &decryptor, BufferedTransformation *attachment = NULLPTR) : SimpleProxyFilter(decryptor.CreateDecryptionFilter(rng), attachment) {} }; @@ -1106,7 +1106,7 @@ public: //! \brief Construct a RandomNumberSink RandomNumberSink() - : m_rng(NULL) {} + : m_rng(NULLPTR) {} //! \brief Construct a RandomNumberSink //! \param rng a RandomNumberGenerator derived class @@ -1132,7 +1132,7 @@ public: //! \param parameters a set of NameValuePairs to initialize this object //! \details Name::OutputBuffer() is a mandatory parameter using this constructor. ArraySink(const NameValuePairs ¶meters = g_nullNameValuePairs) - : m_buf(NULL), m_size(0), m_total(0) {IsolatedInitialize(parameters);} + : m_buf(NULLPTR), m_size(0), m_total(0) {IsolatedInitialize(parameters);} //! \brief Construct an ArraySink //! \param buf pointer to a memory buffer @@ -1184,7 +1184,7 @@ class StringStore : public Store public: //! \brief Construct a StringStore //! \param string pointer to a C-String - StringStore(const char *string = NULL) + StringStore(const char *string = NULLPTR) {StoreInitialize(MakeParameters("InputBuffer", ConstByteArrayParameter(string)));} //! \brief Construct a StringStore @@ -1218,7 +1218,7 @@ public: virtual ~RandomNumberStore() {} RandomNumberStore() - : m_rng(NULL), m_length(0), m_count(0) {} + : m_rng(NULLPTR), m_length(0), m_count(0) {} RandomNumberStore(RandomNumberGenerator &rng, lword length) : m_rng(&rng), m_length(length), m_count(0) {} @@ -1274,7 +1274,7 @@ public: //! \brief Construct a Source //! \param attachment an optional attached transformation - Source(BufferedTransformation *attachment = NULL) + Source(BufferedTransformation *attachment = NULLPTR) {Source::Detach(attachment);} //! \name PIPELINE @@ -1378,14 +1378,14 @@ class CRYPTOPP_DLL StringSource : public SourceTemplate public: //! \brief Construct a StringSource //! \param attachment an optional attached transformation - StringSource(BufferedTransformation *attachment = NULL) + StringSource(BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {} //! \brief Construct a StringSource //! \param string C-String //! \param pumpAll flag indicating if source data should be pumped to its attached transformation //! \param attachment an optional attached transformation - StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment = NULL) + StringSource(const char *string, bool pumpAll, BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));} //! \brief Construct a StringSource @@ -1393,14 +1393,14 @@ public: //! \param length size of the byte array //! \param pumpAll flag indicating if source data should be pumped to its attached transformation //! \param attachment an optional attached transformation - StringSource(const byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment = NULL) + StringSource(const byte *string, size_t length, bool pumpAll, BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string, length)));} //! \brief Construct a StringSource //! \param string std::string //! \param pumpAll flag indicating if source data should be pumped to its attached transformation //! \param attachment an optional attached transformation - StringSource(const std::string &string, bool pumpAll, BufferedTransformation *attachment = NULL) + StringSource(const std::string &string, bool pumpAll, BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("InputBuffer", ConstByteArrayParameter(string)));} }; @@ -1416,7 +1416,7 @@ DOCUMENTED_TYPEDEF(StringSource, ArraySource); class CRYPTOPP_DLL RandomNumberSource : public SourceTemplate { public: - RandomNumberSource(RandomNumberGenerator &rng, int length, bool pumpAll, BufferedTransformation *attachment = NULL) + RandomNumberSource(RandomNumberGenerator &rng, int length, bool pumpAll, BufferedTransformation *attachment = NULLPTR) : SourceTemplate(attachment) {SourceInitialize(pumpAll, MakeParameters("RandomNumberGeneratorPointer", &rng)("RandomNumberStoreSize", length));} }; diff --git a/fips140.cpp b/fips140.cpp index ebf0225e..f95f4005 100644 --- a/fips140.cpp +++ b/fips140.cpp @@ -52,7 +52,7 @@ ThreadLocalStorage & AccessPowerUpSelfTestInProgress() bool PowerUpSelfTestInProgressOnThisThread() { #if CRYPTOPP_ENABLE_COMPLIANCE_WITH_FIPS_140_2 - return AccessPowerUpSelfTestInProgress().GetValue() != NULL; + return AccessPowerUpSelfTestInProgress().GetValue() != NULLPTR; #else CRYPTOPP_ASSERT(false); // should not be called return false; diff --git a/fips140.h b/fips140.h index ecf60147..eb276125 100644 --- a/fips140.h +++ b/fips140.h @@ -86,7 +86,7 @@ CRYPTOPP_DLL MessageAuthenticationCode * CRYPTOPP_API NewIntegrityCheckingMAC(); //! \param pActualMac the actual MAC of the components calculated by the integrity check //! \param pMacFileLocation the offest of the MAC in the PE/PE+ module //! \returns true if the MAC is valid, false otherwise -CRYPTOPP_DLL bool CRYPTOPP_API IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac = NULL, unsigned long *pMacFileLocation = NULL); +CRYPTOPP_DLL bool CRYPTOPP_API IntegrityCheckModule(const char *moduleFilename, const byte *expectedModuleMac, SecByteBlock *pActualMac = NULLPTR, unsigned long *pMacFileLocation = NULLPTR); #ifndef CRYPTOPP_DOXYGEN_PROCESSING // this is used by Algorithm constructor to allow Algorithm objects to be constructed for the self test diff --git a/fipsalgt.cpp b/fipsalgt.cpp index f0d4fe43..26ce6477 100644 --- a/fipsalgt.cpp +++ b/fipsalgt.cpp @@ -20,7 +20,7 @@ USING_NAMESPACE(std) class LineBreakParser : public AutoSignaling > { public: - LineBreakParser(BufferedTransformation *attachment=NULL, byte lineEnd='\n') + LineBreakParser(BufferedTransformation *attachment=NULLPTR, byte lineEnd='\n') : m_lineEnd(lineEnd) {Detach(attachment);} size_t Put2(const byte *begin, size_t length, int messageEnd, bool blocking) @@ -400,7 +400,7 @@ protected: return (Result *) new typename RSASS::Signer; } - return NULL; + return NULLPTR; } template @@ -417,7 +417,7 @@ protected: else if (hash == "512") return CreateRSA2(standard); else - return NULL; + return NULLPTR; } virtual void DoTest() @@ -1259,7 +1259,7 @@ int FIPS_140_AlgorithmTest(int argc, char **argv) test = "KAT"; bool encrypt = (filename.find("vrct") == std::string::npos); - BufferedTransformation *pSink = NULL; + BufferedTransformation *pSink = NULLPTR; if (argc > 3) { diff --git a/fipstest.cpp b/fipstest.cpp index 5721bc82..ccaed1b3 100644 --- a/fipstest.cpp +++ b/fipstest.cpp @@ -67,7 +67,7 @@ static const byte s_moduleMac[CryptoPP::HMAC::DIGESTSIZE] = CRYP CRYPTOPP_COMPILE_ASSERT(sizeof(s_moduleMac) == CryptoPP::SHA1::DIGESTSIZE); #ifdef CRYPTOPP_WIN32_AVAILABLE -static HMODULE s_hModule = NULL; +static HMODULE s_hModule = NULLPTR; #endif const byte * CRYPTOPP_API GetActualMacAndLocation(unsigned int &macSize, unsigned int &fileLocation) @@ -197,7 +197,7 @@ void SignatureKnownAnswerTest(const char *key, const char *message, const char * comparison.ChannelMessageSeriesEnd("0"); comparison.ChannelMessageSeriesEnd("1"); - SignatureVerificationFilter verifierFilter(verifier, NULL, SignatureVerificationFilter::SIGNATURE_AT_BEGIN | SignatureVerificationFilter::THROW_EXCEPTION); + SignatureVerificationFilter verifierFilter(verifier, NULLPTR, SignatureVerificationFilter::SIGNATURE_AT_BEGIN | SignatureVerificationFilter::THROW_EXCEPTION); StringSource(signature, true, new HexDecoder(new Redirector(verifierFilter, Redirector::DATA_ONLY))); StringSource(message, true, new Redirector(verifierFilter)); } @@ -250,7 +250,7 @@ void SignaturePairwiseConsistencyTest(const PK_Signer &signer, const PK_Verifier new SignerFilter( rng, signer, - new SignatureVerificationFilter(verifier, NULL, SignatureVerificationFilter::THROW_EXCEPTION), + new SignatureVerificationFilter(verifier, NULLPTR, SignatureVerificationFilter::THROW_EXCEPTION), true)); } catch (...) @@ -292,11 +292,11 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule std::ifstream moduleStream; #ifdef CRYPTOPP_WIN32_AVAILABLE - HMODULE h = NULL; + HMODULE h = NULLPTR; { const size_t FIPS_MODULE_MAX_PATH = 2*MAX_PATH; char moduleFilenameBuf[FIPS_MODULE_MAX_PATH] = ""; - if (moduleFilename == NULL) + if (moduleFilename == NULLPTR) { #if (_MSC_VER >= 1400 && !defined(_STLPORT_VERSION)) // ifstream doesn't support wide filename on other compilers wchar_t wideModuleFilename[FIPS_MODULE_MAX_PATH]; @@ -313,12 +313,12 @@ bool IntegrityCheckModule(const char *moduleFilename, const byte *expectedModule } } #endif - if (moduleFilename != NULL) + if (moduleFilename != NULLPTR) { moduleStream.open(moduleFilename, std::ios::in | std::ios::binary); #ifdef CRYPTOPP_WIN32_AVAILABLE h = GetModuleHandleA(moduleFilename); - moduleFilename = NULL; + moduleFilename = NULLPTR; } #endif } @@ -467,7 +467,7 @@ void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac try { - if (FIPS_140_2_ComplianceEnabled() || expectedModuleMac != NULL) + if (FIPS_140_2_ComplianceEnabled() || expectedModuleMac != NULLPTR) { if (!IntegrityCheckModule(moduleFilename, expectedModuleMac, &g_actualMac, &g_macFileLocation)) throw 0; // throw here so we break in the debugger, this will be caught right away @@ -509,16 +509,16 @@ void DoPowerUpSelfTest(const char *moduleFilename, const byte *expectedModuleMac "7649abac8119b246cee98e9b12e9197d5086cb9b507219ee95db113a917678b273bed6b8e3c1743b7116e69e222295163ff1caa1681fac09120eca307586e1a7", // cbc "3b3fd92eb72dad20333449f8e83cfb4ac8a64537a0b3a93fcde3cdad9f1ce58b26751f67a3cbb140b1808cf187a4f4dfc04b05357c5d1c0eeac4c66f9ff7f2e6", // cfb "3b3fd92eb72dad20333449f8e83cfb4a7789508d16918f03f53c52dac54ed8259740051e9c5fecf64344f7a82260edcc304c6528f659c77866a510d9c1d6ae5e", // ofb - NULL); + NULLPTR); SymmetricEncryptionKnownAnswerTest( "2b7e151628aed2a6abf7158809cf4f3c", "f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff", "6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710", - NULL, - NULL, - NULL, - NULL, + NULLPTR, + NULLPTR, + NULLPTR, + NULLPTR, "874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee"); // ctr @@ -615,7 +615,7 @@ done: void DoDllPowerUpSelfTest() { - CryptoPP::DoPowerUpSelfTest(NULL, s_moduleMac); + CryptoPP::DoPowerUpSelfTest(NULLPTR, s_moduleMac); } #else diff --git a/fltrimpl.h b/fltrimpl.h index 1577ca7d..d236a6c8 100644 --- a/fltrimpl.h +++ b/fltrimpl.h @@ -30,7 +30,7 @@ /* #define FILTER_END \ case -1: \ - if (messageEnd && Output(-1, NULL, 0, messageEnd, blocking)) \ + if (messageEnd && Output(-1, NULLPTR, 0, messageEnd, blocking)) \ return 1; \ FILTER_END_NO_MESSAGE_END */ diff --git a/gcm.cpp b/gcm.cpp index 0337879b..6d86bac1 100644 --- a/gcm.cpp +++ b/gcm.cpp @@ -174,7 +174,7 @@ void gcm_gf_mult(const unsigned char *a, const unsigned char *b, unsigned char * V0 = (V0>>1) ^ (x ? W64LIT(0xe1) << 56 : 0); } } - Block::Put(NULL, c)(Z0)(Z1); + Block::Put(NULLPTR, c)(Z0)(Z1); } __m128i _mm_clmulepi64_si128(const __m128i &a, const __m128i &b, int i) @@ -421,7 +421,7 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const for (i=0; i<128; i++) { k = i%8; - Block::Put(NULL, table+(i/8)*256*16+(size_t(1)<<(11-k)))(V0)(V1); + Block::Put(NULLPTR, table+(i/8)*256*16+(size_t(1)<<(11-k)))(V0)(V1); int x = (int)V1 & 1; V1 = (V1>>1) | (V0<<63); @@ -470,9 +470,9 @@ void GCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const { k = i%32; if (k < 4) - Block::Put(NULL, table+1024+(i/32)*256+(size_t(1)<<(7-k)))(V0)(V1); + Block::Put(NULLPTR, table+1024+(i/32)*256+(size_t(1)<<(7-k)))(V0)(V1); else if (k < 8) - Block::Put(NULL, table+(i/32)*256+(size_t(1)<<(11-k)))(V0)(V1); + Block::Put(NULLPTR, table+(i/32)*256+(size_t(1)<<(11-k)))(V0)(V1); int x = (int)V1 & 1; V1 = (V1>>1) | (V0<<63); @@ -561,7 +561,7 @@ void GCM_Base::Resync(const byte *iv, size_t len) GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE); } - PutBlock(NULL, m_buffer)(0)(origLen*8); + PutBlock(NULLPTR, m_buffer)(0)(origLen*8); GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE); ReverseHashBufferIfNeeded(); @@ -1172,7 +1172,7 @@ void GCM_Base::AuthenticateLastHeaderBlock() void GCM_Base::AuthenticateLastConfidentialBlock() { GCM_Base::AuthenticateLastHeaderBlock(); - PutBlock(NULL, m_buffer)(m_totalHeaderLength*8)(m_totalMessageLength*8); + PutBlock(NULLPTR, m_buffer)(m_totalHeaderLength*8)(m_totalMessageLength*8); GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE); } diff --git a/gf2n.cpp b/gf2n.cpp index 7a41e3b5..e5e11207 100644 --- a/gf2n.cpp +++ b/gf2n.cpp @@ -902,7 +902,7 @@ GF2NP * BERDecodeGF2NP(BufferedTransformation &bt) else { BERDecodeError(); - return NULL; + return NULLPTR; } parameters.MessageEnd(); seq.MessageEnd(); diff --git a/gfpcrypt.cpp b/gfpcrypt.cpp index 9b6b2ec1..9e821c91 100644 --- a/gfpcrypt.cpp +++ b/gfpcrypt.cpp @@ -245,7 +245,7 @@ Integer DL_GroupParameters_IntegerBased::DecodeElement(const byte *encoded, bool { CRYPTOPP_UNUSED(checkForGroupMembership); Integer g(encoded, GetModulus().ByteCount()); - if (!ValidateElement(1, g, NULL)) + if (!ValidateElement(1, g, NULLPTR)) throw DL_BadElement(); return g; } diff --git a/gfpcrypt.h b/gfpcrypt.h index 7d25490e..75e99705 100644 --- a/gfpcrypt.h +++ b/gfpcrypt.h @@ -811,7 +811,7 @@ public: void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plaintext, size_t plaintextLength, byte *ciphertext, const NameValuePairs ¶meters) const { CRYPTOPP_UNUSED(rng); - const byte *cipherKey = NULL, *macKey = NULL; + const byte *cipherKey = NULLPTR, *macKey = NULLPTR; if (DHAES_MODE) { macKey = key; diff --git a/gzip.h b/gzip.h index 74304d81..a53a23e4 100644 --- a/gzip.h +++ b/gzip.h @@ -26,13 +26,13 @@ public: //! \details detectUncompressible makes it faster to process uncompressible files, but //! if a file has both compressible and uncompressible parts, it may fail to compress //! some of the compressible parts. - Gzip(BufferedTransformation *attachment=NULL, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true) + Gzip(BufferedTransformation *attachment=NULLPTR, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true) : Deflator(attachment, deflateLevel, log2WindowSize, detectUncompressible), m_totalLen(0) {} //! \brief Construct a Gzip compressor //! \param parameters a set of NameValuePairs to initialize this object //! \param attachment an attached transformation //! \details Possible parameter names: Log2WindowSize, DeflateLevel, DetectUncompressible - Gzip(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULL) + Gzip(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULLPTR) : Deflator(parameters, attachment), m_totalLen(0) {} protected: @@ -71,7 +71,7 @@ public: //! \param attachment an attached transformation //! \param repeat decompress multiple compressed streams in series //! \param autoSignalPropagation 0 to turn off MessageEnd signal - Gunzip(BufferedTransformation *attachment = NULL, bool repeat = false, int autoSignalPropagation = -1); + Gunzip(BufferedTransformation *attachment = NULLPTR, bool repeat = false, int autoSignalPropagation = -1); protected: enum { diff --git a/hex.h b/hex.h index 798a0fc5..008a6dbb 100644 --- a/hex.h +++ b/hex.h @@ -22,7 +22,7 @@ public: //! \param groupSize the size of the output grouping //! \param separator the separator to use between groups //! \param terminator the terminator append after processing - HexEncoder(BufferedTransformation *attachment = NULL, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "") + HexEncoder(BufferedTransformation *attachment = NULLPTR, bool uppercase = true, int groupSize = 0, const std::string &separator = ":", const std::string &terminator = "") : SimpleProxyFilter(new BaseN_Encoder(new Grouper), attachment) { IsolatedInitialize(MakeParameters(Name::Uppercase(), uppercase)(Name::GroupSize(), groupSize)(Name::Separator(), ConstByteArrayParameter(separator))(Name::Terminator(), ConstByteArrayParameter(terminator))); @@ -38,7 +38,7 @@ class CRYPTOPP_DLL HexDecoder : public BaseN_Decoder public: //! \brief Construct a HexDecoder //! \param attachment a BufferedTrasformation to attach to this object - HexDecoder(BufferedTransformation *attachment = NULL) + HexDecoder(BufferedTransformation *attachment = NULLPTR) : BaseN_Decoder(GetDefaultDecodingLookupArray(), 4, attachment) {} void IsolatedInitialize(const NameValuePairs ¶meters); diff --git a/hkdf.h b/hkdf.h index 68382d79..a77d9876 100644 --- a/hkdf.h +++ b/hkdf.h @@ -22,7 +22,7 @@ public: virtual size_t MaxDerivedKeyLength() const =0; virtual bool Usesinfo() const =0; //! derive a key from secret - virtual unsigned int DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info=NULL, size_t infoLen=0) const =0; + virtual unsigned int DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info=NULLPTR, size_t infoLen=0) const =0; virtual ~KeyDerivationFunction() {} }; @@ -47,7 +47,7 @@ public: unsigned int DeriveKey(byte *derived, size_t derivedLen, const byte *secret, size_t secretLen, const byte *salt, size_t saltLen, const byte* info, size_t infoLen) const; protected: - // If salt is missing (NULL), then use the NULL vector. Missing is different than EMPTY (0 length). The length + // If salt is missing (NULLPTR), then use the NULL vector. Missing is different than EMPTY (0 length). The length // of s_NullVector used depends on the Hash function. SHA-256 will use 32 bytes of s_NullVector. typedef byte NullVectorType[SALTSIZE]; static const NullVectorType& GetNullVector() { diff --git a/hmqv.h b/hmqv.h index 2abe00c7..c25e5f1b 100644 --- a/hmqv.h +++ b/hmqv.h @@ -125,7 +125,7 @@ public: const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey, bool validateStaticOtherPublicKey=true) const { - byte *XX = NULL, *YY = NULL, *AA = NULL, *BB = NULL; + byte *XX = NULLPTR, *YY = NULLPTR, *AA = NULLPTR, *BB = NULLPTR; size_t xxs = 0, yys = 0, aas = 0, bbs = 0; // Depending on the role, this will hold either A's or B's static @@ -176,13 +176,13 @@ public: // VerifyPoint to ensure the element is in G*. If the other's PublicKey is // requested to be validated, we manually call ValidateElement at level 3. Element VV1 = params.DecodeElement(staticOtherPublicKey, false); - if(!params.ValidateElement(validateStaticOtherPublicKey ? 3 : 1, VV1, NULL)) + if(!params.ValidateElement(validateStaticOtherPublicKey ? 3 : 1, VV1, NULLPTR)) return false; // DecodeElement calls ValidateElement at level 1. Level 1 only calls // VerifyPoint to ensure the element is in G*. Crank it up. Element VV2 = params.DecodeElement(ephemeralOtherPublicKey, false); - if(!params.ValidateElement(3, VV2, NULL)) + if(!params.ValidateElement(3, VV2, NULLPTR)) return false; // const Integer& p = params.GetGroupOrder(); // not used, remove later @@ -193,11 +193,11 @@ public: SecByteBlock dd(len), ee(len); // Compute $d = \hat{H}(X, \hat{B})$ - Hash(NULL, XX, xxs, BB, bbs, dd.BytePtr(), dd.SizeInBytes()); + Hash(NULLPTR, XX, xxs, BB, bbs, dd.BytePtr(), dd.SizeInBytes()); d.Decode(dd.BytePtr(), dd.SizeInBytes()); // Compute $e = \hat{H}(Y, \hat{A})$ - Hash(NULL, YY, yys, AA, aas, ee.BytePtr(), ee.SizeInBytes()); + Hash(NULLPTR, YY, yys, AA, aas, ee.BytePtr(), ee.SizeInBytes()); e.Decode(ee.BytePtr(), ee.SizeInBytes()); Element sigma; @@ -231,7 +231,7 @@ public: // $\sigma_A}=(Y \cdot B^{e})^{s_A} sigma = params.ExponentiateElement(t2, s_A); } - Hash(&sigma, NULL, 0, NULL, 0, agreedValue, AgreedValueLength()); + Hash(&sigma, NULLPTR, 0, NULLPTR, 0, agreedValue, AgreedValueLength()); } catch (DL_BadElement &) { diff --git a/hrtimer.cpp b/hrtimer.cpp index 82e15d44..1b89dcb2 100644 --- a/hrtimer.cpp +++ b/hrtimer.cpp @@ -97,7 +97,7 @@ TimerWord Timer::GetCurrentTimerValue() return now.QuadPart; #elif defined(CRYPTOPP_UNIX_AVAILABLE) timeval now; - gettimeofday(&now, NULL); + gettimeofday(&now, NULLPTR); return (TimerWord)now.tv_sec * 1000000 + now.tv_usec; #else // clock_t now; diff --git a/ida.cpp b/ida.cpp index d42317f4..125ab979 100644 --- a/ida.cpp +++ b/ida.cpp @@ -279,9 +279,9 @@ size_t SecretSharing::Put2(const byte *begin, size_t length, int messageEnd, boo while (m_ida.InputBuffered(0xffffffff) > 0) SecretSharing::Put(0); } - m_ida.ChannelData(0xffffffff, NULL, 0, true); + m_ida.ChannelData(0xffffffff, NULLPTR, 0, true); for (unsigned int i=0; i > > { public: - RawIDA(BufferedTransformation *attachment=NULL) + RawIDA(BufferedTransformation *attachment=NULLPTR) : m_threshold (0), m_channelsReady(0), m_channelsFinished(0) {Detach(attachment);} @@ -72,7 +72,7 @@ class SecretSharing : public CustomFlushPropagation { public: //! \brief Construct a SecretSharing - SecretSharing(RandomNumberGenerator &rng, int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true) + SecretSharing(RandomNumberGenerator &rng, int threshold, int nShares, BufferedTransformation *attachment=NULLPTR, bool addPadding=true) : m_rng(rng), m_ida(new OutputProxy(*this, true)) { Detach(attachment); @@ -98,7 +98,7 @@ class SecretRecovery : public RawIDA { public: //! \brief Construct a SecretRecovery - SecretRecovery(int threshold, BufferedTransformation *attachment=NULL, bool removePadding=true) + SecretRecovery(int threshold, BufferedTransformation *attachment=NULLPTR, bool removePadding=true) : RawIDA(attachment) {IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("RemovePadding", removePadding));} @@ -122,7 +122,7 @@ class InformationDispersal : public CustomFlushPropagation { public: //! \brief Construct a InformationDispersal - InformationDispersal(int threshold, int nShares, BufferedTransformation *attachment=NULL, bool addPadding=true) + InformationDispersal(int threshold, int nShares, BufferedTransformation *attachment=NULLPTR, bool addPadding=true) : m_ida(new OutputProxy(*this, true)), m_pad(false), m_nextChannel(0) { Detach(attachment); @@ -148,7 +148,7 @@ class InformationRecovery : public RawIDA { public: //! \brief Construct a InformationRecovery - InformationRecovery(int threshold, BufferedTransformation *attachment=NULL, bool removePadding=true) + InformationRecovery(int threshold, BufferedTransformation *attachment=NULLPTR, bool removePadding=true) : RawIDA(attachment), m_pad(false) {IsolatedInitialize(MakeParameters("RecoveryThreshold", threshold)("RemovePadding", removePadding));} @@ -165,7 +165,7 @@ protected: class PaddingRemover : public Unflushable { public: - PaddingRemover(BufferedTransformation *attachment=NULL) + PaddingRemover(BufferedTransformation *attachment=NULLPTR) : m_possiblePadding(false), m_zeroCount(0) {Detach(attachment);} void IsolatedInitialize(const NameValuePairs ¶meters) diff --git a/integer.cpp b/integer.cpp index 0fae68be..0defd45a 100644 --- a/integer.cpp +++ b/integer.cpp @@ -400,7 +400,7 @@ private: // do a 3 word by 2 word divide, returns quotient and leaves remainder in A template -S DivideThreeWordsByTwo(S *A, S B0, S B1, D *dummy=NULL) +S DivideThreeWordsByTwo(S *A, S B0, S B1, D *dummy=NULLPTR) { CRYPTOPP_UNUSED(dummy); @@ -3496,7 +3496,7 @@ public: CRYPTOPP_ASSERT(output && size); // NULL buffer PutWord(false, BIG_ENDIAN_ORDER, m_counterAndSeed, m_counter); ++m_counter; - P1363_KDF2::DeriveKey(output, size, m_counterAndSeed, m_counterAndSeed.size(), NULL, 0); + P1363_KDF2::DeriveKey(output, size, m_counterAndSeed, m_counterAndSeed.size(), NULLPTR, 0); } private: @@ -3565,7 +3565,7 @@ bool Integer::GenerateRandomNoThrow(RandomNumberGenerator &i_rng, const NameValu case PRIME: { - const PrimeSelector *pSelector = params.GetValueWithDefault(Name::PointerToPrimeSelector(), (const PrimeSelector *)NULL); + const PrimeSelector *pSelector = params.GetValueWithDefault(Name::PointerToPrimeSelector(), (const PrimeSelector *)NULLPTR); int i; i = 0; diff --git a/keccak.cpp b/keccak.cpp index 5ada498e..b9abd396 100644 --- a/keccak.cpp +++ b/keccak.cpp @@ -245,7 +245,7 @@ static void KeccakF1600(word64 *state) } //copyToState(state, A) - Block::Put(NULL, state)(Aba)(Abe)(Abi)(Abo)(Abu)(Aga)(Age)(Agi)(Ago)(Agu)(Aka)(Ake)(Aki)(Ako)(Aku)(Ama)(Ame)(Ami)(Amo)(Amu)(Asa)(Ase)(Asi)(Aso)(Asu); + Block::Put(NULLPTR, state)(Aba)(Abe)(Abi)(Abo)(Abu)(Aga)(Age)(Agi)(Ago)(Agu)(Aka)(Ake)(Aki)(Ako)(Aku)(Ama)(Ame)(Ami)(Amo)(Amu)(Asa)(Ase)(Asi)(Aso)(Asu); } } diff --git a/misc.cpp b/misc.cpp index 7bc646a2..42b70161 100644 --- a/misc.cpp +++ b/misc.cpp @@ -27,8 +27,8 @@ NAMESPACE_BEGIN(CryptoPP) void xorbuf(byte *buf, const byte *mask, size_t count) { - CRYPTOPP_ASSERT(buf != NULL); - CRYPTOPP_ASSERT(mask != NULL); + CRYPTOPP_ASSERT(buf != NULLPTR); + CRYPTOPP_ASSERT(mask != NULLPTR); CRYPTOPP_ASSERT(count > 0); size_t i=0; @@ -60,8 +60,8 @@ void xorbuf(byte *buf, const byte *mask, size_t count) void xorbuf(byte *output, const byte *input, const byte *mask, size_t count) { - CRYPTOPP_ASSERT(output != NULL); - CRYPTOPP_ASSERT(input != NULL); + CRYPTOPP_ASSERT(output != NULLPTR); + CRYPTOPP_ASSERT(input != NULLPTR); CRYPTOPP_ASSERT(count > 0); size_t i=0; @@ -95,8 +95,8 @@ void xorbuf(byte *output, const byte *input, const byte *mask, size_t count) bool VerifyBufsEqual(const byte *buf, const byte *mask, size_t count) { - CRYPTOPP_ASSERT(buf != NULL); - CRYPTOPP_ASSERT(mask != NULL); + CRYPTOPP_ASSERT(buf != NULLPTR); + CRYPTOPP_ASSERT(mask != NULLPTR); CRYPTOPP_ASSERT(count > 0); size_t i=0; @@ -147,7 +147,7 @@ std::string StringNarrow(const wchar_t *str, bool throwOnError) //while (*ptr++) len++; len = wcslen(str)+1; - err = wcstombs_s(&size, NULL, 0, str, len*sizeof(wchar_t)); + err = wcstombs_s(&size, NULLPTR, 0, str, len*sizeof(wchar_t)); CRYPTOPP_ASSERT(err == 0); if (err != 0) { @@ -172,7 +172,7 @@ std::string StringNarrow(const wchar_t *str, bool throwOnError) if (!result.empty() && result[size - 1] == '\0') result.erase(size - 1); #else - size_t size = wcstombs(NULL, str, 0); + size_t size = wcstombs(NULLPTR, str, 0); CRYPTOPP_ASSERT(size != (size_t)-1); if (size == (size_t)-1) { @@ -202,7 +202,7 @@ void CallNewHandler() using std::new_handler; using std::set_new_handler; - new_handler newHandler = set_new_handler(NULL); + new_handler newHandler = set_new_handler(NULLPTR); if (newHandler) set_new_handler(newHandler); @@ -218,15 +218,15 @@ void * AlignedAllocate(size_t size) { byte *p; #if defined(CRYPTOPP_APPLE_ALLOC_AVAILABLE) - while ((p = (byte *)calloc(1, size)) == NULL) + while ((p = (byte *)calloc(1, size)) == NULLPTR) #elif defined(CRYPTOPP_MM_MALLOC_AVAILABLE) - while ((p = (byte *)_mm_malloc(size, 16)) == NULL) + while ((p = (byte *)_mm_malloc(size, 16)) == NULLPTR) #elif defined(CRYPTOPP_MEMALIGN_AVAILABLE) - while ((p = (byte *)memalign(16, size)) == NULL) + while ((p = (byte *)memalign(16, size)) == NULLPTR) #elif defined(CRYPTOPP_MALLOC_ALIGNMENT_IS_16) - while ((p = (byte *)malloc(size)) == NULL) + while ((p = (byte *)malloc(size)) == NULLPTR) #else - while ((p = (byte *)malloc(size + 16)) == NULL) + while ((p = (byte *)malloc(size + 16)) == NULLPTR) #endif CallNewHandler(); @@ -257,7 +257,7 @@ void AlignedDeallocate(void *p) void * UnalignedAllocate(size_t size) { void *p; - while ((p = malloc(size)) == NULL) + while ((p = malloc(size)) == NULLPTR) CallNewHandler(); return p; } diff --git a/misc.h b/misc.h index c187f52d..36daaa92 100644 --- a/misc.h +++ b/misc.h @@ -397,7 +397,7 @@ inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t cou // Safer functions on Windows for C&A, http://github.com/weidai11/cryptopp/issues/55 // Pointers must be valid; otherwise undefined behavior - CRYPTOPP_ASSERT(dest != NULL); CRYPTOPP_ASSERT(src != NULL); + CRYPTOPP_ASSERT(dest != NULLPTR); CRYPTOPP_ASSERT(src != NULLPTR); // Destination buffer must be large enough to satsify request CRYPTOPP_ASSERT(sizeInBytes >= count); if (count > sizeInBytes) @@ -439,7 +439,7 @@ inline void memmove_s(void *dest, size_t sizeInBytes, const void *src, size_t co // Safer functions on Windows for C&A, http://github.com/weidai11/cryptopp/issues/55 // Pointers must be valid; otherwise undefined behavior - CRYPTOPP_ASSERT(dest != NULL); CRYPTOPP_ASSERT(src != NULL); + CRYPTOPP_ASSERT(dest != NULLPTR); CRYPTOPP_ASSERT(src != NULLPTR); // Destination buffer must be large enough to satsify request CRYPTOPP_ASSERT(sizeInBytes >= count); if (count > sizeInBytes) @@ -1067,7 +1067,7 @@ inline CipherDir GetCipherDir(const T &obj) //! \throws bad_alloc //! \details In the normal course of running a program, a request for memory normally succeeds. If a //! call to AlignedAllocate or UnalignedAllocate fails, then CallNewHandler is called in -//! an effort to recover. Internally, CallNewHandler calls set_new_handler(NULL) in an effort +//! an effort to recover. Internally, CallNewHandler calls set_new_handler(NULLPTR) in an effort //! to free memory. There is no guarantee CallNewHandler will be able to procure more memory so //! an allocation succeeds. If the call to set_new_handler fails, then CallNewHandler throws //! a bad_alloc exception. @@ -1081,7 +1081,7 @@ CRYPTOPP_DLL void CRYPTOPP_API CallNewHandler(); //! \note The function is not constant time because it stops processing when the carry is 0. inline void IncrementCounterByOne(byte *inout, unsigned int size) { - CRYPTOPP_ASSERT(inout != NULL); CRYPTOPP_ASSERT(size < INT_MAX); + CRYPTOPP_ASSERT(inout != NULLPTR); CRYPTOPP_ASSERT(size < INT_MAX); for (int i=int(size-1), carry=1; i>=0 && carry; i--) carry = !++inout[i]; } @@ -1095,7 +1095,7 @@ inline void IncrementCounterByOne(byte *inout, unsigned int size) //! \details The function is \a close to near-constant time because it operates on all the bytes in the blocks. inline void IncrementCounterByOne(byte *output, const byte *input, unsigned int size) { - CRYPTOPP_ASSERT(output != NULL); CRYPTOPP_ASSERT(input != NULL); CRYPTOPP_ASSERT(size < INT_MAX); + CRYPTOPP_ASSERT(output != NULLPTR); CRYPTOPP_ASSERT(input != NULLPTR); CRYPTOPP_ASSERT(size < INT_MAX); int i, carry; for (i=int(size-1), carry=1; i>=0 && carry; i--) @@ -2182,7 +2182,7 @@ inline void GetWord(bool assumeAligned, ByteOrder order, T &result, const byte * //! if the memory block is aligned for class or type T. The enumeration ByteOrder is BIG_ENDIAN_ORDER or //! LITTLE_ENDIAN_ORDER. template -inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock = NULL) +inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, const byte *xorBlock = NULLPTR) { CRYPTOPP_UNUSED(assumeAligned); #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS @@ -2250,7 +2250,7 @@ private: //!
 //!    word32 w1=0x03020100, w2=0x07060504;
 //!    byte buffer[8];
-//!    PutBlock block(NULL, buffer);
+//!    PutBlock block(NULLPTR, buffer);
 //!    block(w1)(w2);
 //! 
template diff --git a/modes.cpp b/modes.cpp index 03e8ba80..6b8e81ae 100644 --- a/modes.cpp +++ b/modes.cpp @@ -90,7 +90,7 @@ void OFB_ModePolicy::WriteKeystream(byte *keystreamBuffer, size_t iterationCount unsigned int s = BlockSize(); m_cipher->ProcessBlock(m_register, keystreamBuffer); if (iterationCount > 1) - m_cipher->AdvancedProcessBlocks(keystreamBuffer, NULL, keystreamBuffer+s, s*(iterationCount-1), 0); + m_cipher->AdvancedProcessBlocks(keystreamBuffer, NULLPTR, keystreamBuffer+s, s*(iterationCount-1), 0); memcpy(m_register, keystreamBuffer+s*(iterationCount-1), s); } @@ -169,7 +169,7 @@ void BlockOrientedCipherModeBase::ResizeBuffers() void ECB_OneWay::ProcessData(byte *outString, const byte *inString, size_t length) { CRYPTOPP_ASSERT(length%BlockSize()==0); - m_cipher->AdvancedProcessBlocks(inString, NULL, outString, length, BlockTransformation::BT_AllowParallel); + m_cipher->AdvancedProcessBlocks(inString, NULLPTR, outString, length, BlockTransformation::BT_AllowParallel); } void CBC_Encryption::ProcessData(byte *outString, const byte *inString, size_t length) diff --git a/modes.h b/modes.h index eb1a3ef6..78f2cd97 100644 --- a/modes.h +++ b/modes.h @@ -73,7 +73,7 @@ public: } protected: - CipherModeBase() : m_cipher(NULL) {} + CipherModeBase() : m_cipher(NULLPTR) {} inline unsigned int BlockSize() const {CRYPTOPP_ASSERT(m_register.size() > 0); return (unsigned int)m_register.size();} virtual void SetFeedbackSize(unsigned int feedbackSize) { @@ -172,7 +172,7 @@ protected: unsigned int GetBytesPerIteration() const {return BlockSize();} unsigned int GetIterationsToBuffer() const {return m_cipher->OptimalNumberOfParallelBlocks();} void WriteKeystream(byte *buffer, size_t iterationCount) - {OperateKeystream(WRITE_KEYSTREAM, buffer, NULL, iterationCount);} + {OperateKeystream(WRITE_KEYSTREAM, buffer, NULLPTR, iterationCount);} bool CanOperateKeystream() const {return true;} void OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount); void CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length); @@ -250,7 +250,7 @@ protected: void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms) { CBC_Encryption::UncheckedSetKey(key, length, params); - m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULL); + m_stolenIV = params.GetValueWithDefault(Name::StolenIV(), (byte *)NULLPTR); } byte *m_stolenIV; diff --git a/mqueue.h b/mqueue.h index 08007987..5c9bcdc8 100644 --- a/mqueue.h +++ b/mqueue.h @@ -74,7 +74,7 @@ public: struct MismatchDetected : public Exception {MismatchDetected() : Exception(DATA_INTEGRITY_CHECK_FAILED, "EqualityComparisonFilter: did not receive the same data on two channels") {}}; /*! if throwIfNotEqual is false, this filter will output a '\\0' byte when it detects a mismatch, '\\1' otherwise */ - EqualityComparisonFilter(BufferedTransformation *attachment=NULL, bool throwIfNotEqual=true, const std::string &firstChannel="0", const std::string &secondChannel="1") + EqualityComparisonFilter(BufferedTransformation *attachment=NULLPTR, bool throwIfNotEqual=true, const std::string &firstChannel="0", const std::string &secondChannel="1") : m_throwIfNotEqual(throwIfNotEqual), m_mismatchDetected(false) , m_firstChannel(firstChannel), m_secondChannel(secondChannel) {Detach(attachment);} diff --git a/network.cpp b/network.cpp index 31b3d1b6..9195e22b 100644 --- a/network.cpp +++ b/network.cpp @@ -134,7 +134,7 @@ size_t NonblockingSource::GeneralPump2( } WaitObjectContainer container; - LimitedBandwidth::GetWaitObjects(container, CallStack("NonblockingSource::GeneralPump2() - speed limit", 0)); + LimitedBandwidth::GetWaitObjects(container, CallStack("NonblockingSource::GeneralPump2() - speed limit", NULLPTR)); container.Wait((unsigned long)waitTime); } @@ -156,7 +156,7 @@ size_t NonblockingSource::PumpMessages2(unsigned int &messageCount, bool blockin if (!m_messageEndSent && SourceExhausted()) { - RETURN_IF_NONZERO(AttachedTransformation()->Put2(NULL, 0, GetAutoSignalPropagation(), true)); + RETURN_IF_NONZERO(AttachedTransformation()->Put2(NULLPTR, 0, GetAutoSignalPropagation(), true)); m_messageEndSent = true; messageCount = 1; } @@ -214,7 +214,7 @@ lword NonblockingSink::TimedFlush(unsigned long maxTime, size_t targetSize) } WaitObjectContainer container; - LimitedBandwidth::GetWaitObjects(container, CallStack("NonblockingSink::TimedFlush() - speed limit", 0)); + LimitedBandwidth::GetWaitObjects(container, CallStack("NonblockingSink::TimedFlush() - speed limit", NULLPTR)); container.Wait((unsigned long)waitTime); } @@ -282,7 +282,7 @@ size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned lon { if (receiver.MustWaitForResult() && !receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()), - CallStack("NetworkSource::DoPump() - wait receive result", 0))) + CallStack("NetworkSource::DoPump() - wait receive result", NULLPTR))) break; unsigned int recvResult = receiver.GetReceiveResult(); @@ -302,7 +302,7 @@ size_t NetworkSource::DoPump(lword &byteCount, bool blockingOutput, unsigned lon if (receiver.MustWaitToReceive()) { if (!receiver.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()), - CallStack("NetworkSource::DoPump() - wait receive", 0))) + CallStack("NetworkSource::DoPump() - wait receive", NULLPTR))) break; receiver.Receive(m_buf+m_dataEnd, m_buf.size()-m_dataEnd); @@ -345,7 +345,7 @@ DoOutput: if (result) { if (t->Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()), - CallStack("NetworkSource::DoPump() - wait attachment", 0))) + CallStack("NetworkSource::DoPump() - wait attachment", NULLPTR))) goto DoOutput; else { @@ -492,7 +492,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize) { if (sender.MustWaitForResult() && !sender.Wait(SaturatingSubtract(maxTime, timer.ElapsedTime()), - CallStack("NetworkSink::DoFlush() - wait send result", 0))) + CallStack("NetworkSink::DoFlush() - wait send result", NULLPTR))) break; unsigned int sendResult = sender.GetSendResult(); @@ -508,7 +508,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize) } unsigned long timeOut = maxTime ? SaturatingSubtract(maxTime, timer.ElapsedTime()) : 0; - if (sender.MustWaitToSend() && !sender.Wait(timeOut, CallStack("NetworkSink::DoFlush() - wait send", 0))) + if (sender.MustWaitToSend() && !sender.Wait(timeOut, CallStack("NetworkSink::DoFlush() - wait send", NULLPTR))) break; size_t contiguousSize = 0; @@ -538,7 +538,7 @@ lword NetworkSink::DoFlush(unsigned long maxTime, size_t targetSize) while (m_eofState == EOF_PENDING_DELIVERY) { unsigned long timeOut = maxTime ? SaturatingSubtract(maxTime, timer.ElapsedTime()) : 0; - if (!sender.Wait(timeOut, CallStack("NetworkSink::DoFlush() - wait EOF", 0))) + if (!sender.Wait(timeOut, CallStack("NetworkSink::DoFlush() - wait EOF", NULLPTR))) break; if (sender.EofSent()) diff --git a/osrng.h b/osrng.h index 4739e334..85187981 100644 --- a/osrng.h +++ b/osrng.h @@ -194,7 +194,7 @@ public: //! \details Internally, the generator uses SHA256 to extract the entropy from //! from the seed and then stretch the material for the block cipher's key //! and initialization vector. - void Reseed(bool blocking = false, const byte *additionalEntropy = NULL, size_t length = 0); + void Reseed(bool blocking = false, const byte *additionalEntropy = NULLPTR, size_t length = 0); //! \brief Deterministically reseed an AutoSeededX917RNG for testing //! \param key the key to use for the deterministic reseeding @@ -239,7 +239,7 @@ void AutoSeededX917RNG::Reseed(bool blocking, const byte *input, s } // check that seed and key don't have same value while (memcmp(key, seed, STDMIN((unsigned int)BLOCK_CIPHER::BLOCKSIZE, (unsigned int)BLOCK_CIPHER::DEFAULT_KEYLENGTH)) == 0); - Reseed(key, BLOCK_CIPHER::DEFAULT_KEYLENGTH, seed, NULL); + Reseed(key, BLOCK_CIPHER::DEFAULT_KEYLENGTH, seed, NULLPTR); } CRYPTOPP_DLL_TEMPLATE_CLASS AutoSeededX917RNG; diff --git a/ossig.h b/ossig.h index 35e8f789..94395a02 100644 --- a/ossig.h +++ b/ossig.h @@ -67,7 +67,7 @@ struct SignalHandler //! because the destructor may not run. setjmp is why cpu.cpp does not use SignalHandler //! during CPU feature testing. //! \since Crypto++ 5.6.5 - SignalHandler(SignalHandlerFn pfn = NULL, int flags = 0) : m_installed(false) + SignalHandler(SignalHandlerFn pfn = NULLPTR, int flags = 0) : m_installed(false) { // http://pubs.opengroup.org/onlinepubs/007908799/xsh/sigaction.html struct sigaction new_handler; diff --git a/panama.cpp b/panama.cpp index b4b2b93e..7773d4a6 100644 --- a/panama.cpp +++ b/panama.cpp @@ -440,7 +440,7 @@ void PanamaHash::TruncatedFinal(byte *hash, size_t size) this->Iterate(32); // pull FixedSizeSecBlock buf; - this->Iterate(1, NULL, buf.BytePtr(), NULL); + this->Iterate(1, NULLPTR, buf.BytePtr(), NULLPTR); memcpy(hash, buf, size); @@ -479,7 +479,7 @@ void PanamaCipherPolicy::CipherResynchronize(byte *keystreamBuffer, const byt #if (CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE || defined(CRYPTOPP_X64_MASM_AVAILABLE)) && !defined(CRYPTOPP_DISABLE_PANAMA_ASM) if (B::ToEnum() == LITTLE_ENDIAN_ORDER && HasSSE2() && !IsP4()) // SSE2 code is slower on P4 Prescott - Panama_SSE2_Pull(32, this->m_state, NULL, NULL); + Panama_SSE2_Pull(32, this->m_state, NULLPTR, NULLPTR); else #endif this->Iterate(32); @@ -504,7 +504,7 @@ void PanamaCipherPolicy::OperateKeystream(KeystreamOperation operation, byte Panama_SSE2_Pull(iterationCount, this->m_state, (word32 *)(void *)output, (const word32 *)(void *)input); else #endif - this->Iterate(iterationCount, NULL, output, input, operation); + this->Iterate(iterationCount, NULLPTR, output, input, operation); } template class Panama; diff --git a/panama.h b/panama.h index 9fc3a2ea..505de98a 100644 --- a/panama.h +++ b/panama.h @@ -23,7 +23,7 @@ class CRYPTOPP_NO_VTABLE Panama { public: void Reset(); - void Iterate(size_t count, const word32 *p=NULL, byte *output=NULL, const byte *input=NULL, KeystreamOperation operation=WRITE_KEYSTREAM); + void Iterate(size_t count, const word32 *p=NULLPTR, byte *output=NULLPTR, const byte *input=NULLPTR, KeystreamOperation operation=WRITE_KEYSTREAM); protected: typedef word32 Stage[8]; @@ -50,7 +50,7 @@ protected: void Init() {Panama::Reset();} void HashEndianCorrectedBlock(const word32 *data) {this->Iterate(1, data);} // push size_t HashMultipleBlocks(const word32 *input, size_t length); - word32* StateBuf() {return NULL;} + word32* StateBuf() {return NULLPTR;} }; } diff --git a/poly1305.cpp b/poly1305.cpp index d74896f9..f580fc42 100644 --- a/poly1305.cpp +++ b/poly1305.cpp @@ -243,7 +243,7 @@ void Poly1305_Base::Resynchronize(const byte *nonce, int nonceLength) { CRYPTOPP_ASSERT(nonceLength == -1 || nonceLength == (int)BLOCKSIZE); nonceLength == -1 ? nonceLength = BLOCKSIZE : nonceLength; - this->UncheckedSetKey(NULL, 0, MakeParameters(Name::IV(), ConstByteArrayParameter(nonce, nonceLength))); + this->UncheckedSetKey(NULLPTR, 0, MakeParameters(Name::IV(), ConstByteArrayParameter(nonce, nonceLength))); } template diff --git a/poly1305.h b/poly1305.h index 773bd27d..2ac7847c 100644 --- a/poly1305.h +++ b/poly1305.h @@ -160,7 +160,7 @@ public: //! bytes used for r. //! \details Each message requires a unique security context. You can use GetNextIV() and //! Resynchronize() to set a new nonce under a key for a message. - Poly1305(const byte *key, size_t keyLength=DEFAULT_KEYLENGTH, const byte *nonce=NULL, size_t nonceLength=0) + Poly1305(const byte *key, size_t keyLength=DEFAULT_KEYLENGTH, const byte *nonce=NULLPTR, size_t nonceLength=0) {this->SetKey(key, keyLength, MakeParameters(Name::IV(), ConstByteArrayParameter(nonce, nonceLength)));} }; diff --git a/pubkey.cpp b/pubkey.cpp index 7ce80412..3a600906 100644 --- a/pubkey.cpp +++ b/pubkey.cpp @@ -30,7 +30,7 @@ bool PK_DeterministicSignatureMessageEncodingMethod::VerifyMessageRepresentative byte *representative, size_t representativeBitLength) const { SecByteBlock computedRepresentative(BitsToBytes(representativeBitLength)); - ComputeMessageRepresentative(NullRNG(), NULL, 0, hash, hashIdentifier, messageEmpty, computedRepresentative, representativeBitLength); + ComputeMessageRepresentative(NullRNG(), NULLPTR, 0, hash, hashIdentifier, messageEmpty, computedRepresentative, representativeBitLength); return VerifyBufsEqual(representative, computedRepresentative, computedRepresentative.size()); } @@ -64,7 +64,7 @@ void TF_SignerBase::InputRecoverableMessage(PK_MessageAccumulator &messageAccumu encoding.ProcessRecoverableMessage( ma.AccessHash(), recoverableMessage, recoverableMessageLength, - NULL, 0, ma.m_semisignature); + NULLPTR, 0, ma.m_semisignature); } size_t TF_SignerBase::SignAndRestart(RandomNumberGenerator &rng, PK_MessageAccumulator &messageAccumulator, byte *signature, bool restart) const diff --git a/pubkey.h b/pubkey.h index 2bbb88be..888ad3e6 100644 --- a/pubkey.h +++ b/pubkey.h @@ -391,7 +391,7 @@ public: { static HashIdentifier CRYPTOPP_API Lookup() { - return HashIdentifier((const byte *)NULL, 0); + return HashIdentifier((const byte *)NULLPTR, 0); } }; }; @@ -609,7 +609,7 @@ class TF_ObjectImplExtRef : public TF_ObjectImplBase public: virtual ~TF_ObjectImplExtRef() {} - TF_ObjectImplExtRef(const KEY *pKey = NULL) : m_pKey(pKey) {} + TF_ObjectImplExtRef(const KEY *pKey = NULLPTR) : m_pKey(pKey) {} void SetKeyPtr(const KEY *pKey) {m_pKey = pKey;} const KEY & GetKey() const {return *m_pKey;} @@ -699,7 +699,7 @@ public: CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "MGF1";} void GenerateAndMask(HashTransformation &hash, byte *output, size_t outputLength, const byte *input, size_t inputLength, bool mask = true) const { - P1363_MGF1KDF2_Common(hash, output, outputLength, input, inputLength, NULL, 0, mask, 0); + P1363_MGF1KDF2_Common(hash, output, outputLength, input, inputLength, NULLPTR, 0, mask, 0); } }; @@ -1061,7 +1061,7 @@ public: template void DL_PublicKey::AssignFrom(const NameValuePairs &source) { - DL_PrivateKey *pPrivateKey = NULL; + DL_PrivateKey *pPrivateKey = NULLPTR; if (source.GetThisPointer(pPrivateKey)) pPrivateKey->MakePublicKey(*this); else @@ -1965,7 +1965,7 @@ public: if (params.FastSubgroupCheckAvailable()) { - if (!params.ValidateElement(2, publicElement, NULL)) + if (!params.ValidateElement(2, publicElement, NULLPTR)) throw DL_BadElement(); return params.ExponentiateElement(publicElement, privateExponent); } diff --git a/queue.cpp b/queue.cpp index a0353747..8bf43d99 100644 --- a/queue.cpp +++ b/queue.cpp @@ -19,7 +19,7 @@ public: : buf(maxSize) { m_head = m_tail = 0; - next = 0; + next = NULLPTR; } inline size_t MaxSize() const {return buf.size();} @@ -132,7 +132,7 @@ public: ByteQueue::ByteQueue(size_t nodeSize) : Bufferless(), m_autoNodeSize(!nodeSize), m_nodeSize(nodeSize) - , m_head(NULL), m_tail(NULL), m_lazyString(NULL), m_lazyLength(0), m_lazyStringModifiable(false) + , m_head(NULLPTR), m_tail(NULLPTR), m_lazyString(NULLPTR), m_lazyLength(0), m_lazyStringModifiable(false) { SetNodeSize(nodeSize); m_head = m_tail = new ByteQueueNode(m_nodeSize); @@ -145,7 +145,7 @@ void ByteQueue::SetNodeSize(size_t nodeSize) } ByteQueue::ByteQueue(const ByteQueue ©) - : Bufferless(copy), m_lazyString(NULL), m_lazyLength(0) + : Bufferless(copy), m_lazyString(NULLPTR), m_lazyLength(0) { CopyFrom(copy); } @@ -163,7 +163,7 @@ void ByteQueue::CopyFrom(const ByteQueue ©) m_tail = m_tail->next; } - m_tail->next = NULL; + m_tail->next = NULLPTR; Put(copy.m_lazyString, copy.m_lazyLength); } @@ -213,7 +213,7 @@ void ByteQueue::Clear() m_tail = m_head; m_head->Clear(); - m_head->next = NULL; + m_head->next = NULLPTR; m_lazyLength = 0; } diff --git a/queue.h b/queue.h index a7e3a755..c9c9f76f 100644 --- a/queue.h +++ b/queue.h @@ -1,7 +1,6 @@ // queue.h - originally written and placed in the public domain by Wei Dai //! \file -//! \headerfile queue.h //! \brief Classes for an unlimited queue to store bytes #ifndef CRYPTOPP_QUEUE_H @@ -82,7 +81,7 @@ public: //! \brief Construct a ByteQueue Walker //! \param queue a ByteQueue Walker(const ByteQueue &queue) - : m_queue(queue), m_node(NULL), m_position(0), m_offset(0), m_lazyString(NULL), m_lazyLength(0) + : m_queue(queue), m_node(NULLPTR), m_position(0), m_offset(0), m_lazyString(NULLPTR), m_lazyLength(0) {Initialize();} lword GetCurrentPosition() {return m_position;} diff --git a/randpool.cpp b/randpool.cpp index 51cec5d6..a7d2efdf 100644 --- a/randpool.cpp +++ b/randpool.cpp @@ -46,7 +46,7 @@ void RandomPool::GenerateIntoBufferedTransformation(BufferedTransformation &targ TimerWord tw = timer.GetCurrentTimerValue(); *(TimerWord *)(void*)m_seed.data() += tw; - time_t t = time(NULL); + time_t t = time(NULLPTR); // UBsan finding: signed integer overflow: 1876017710 + 1446085457 cannot be represented in type 'long int' // *(time_t *)(m_seed.data()+8) += t; diff --git a/rdrand.cpp b/rdrand.cpp index 6eb45f8f..db1f336e 100644 --- a/rdrand.cpp +++ b/rdrand.cpp @@ -255,7 +255,7 @@ static int GCC_RRA_GenerateBlock(byte *output, size_t size, unsigned int safety) { if (size >= sizeof(val)) { - PutWord(true, LITTLE_ENDIAN_ORDER, output, val, NULL); + PutWord(true, LITTLE_ENDIAN_ORDER, output, val, NULLPTR); output += sizeof(val); size -= sizeof(val); } @@ -424,7 +424,7 @@ static int GCC_RSA_GenerateBlock(byte *output, size_t size, unsigned int safety) { if (size >= sizeof(val)) { - PutWord(true, LITTLE_ENDIAN_ORDER, output, val, NULL); + PutWord(true, LITTLE_ENDIAN_ORDER, output, val, NULLPTR); output += sizeof(val); size -= sizeof(val); } diff --git a/rijndael.cpp b/rijndael.cpp index 37237be6..ee8a4907 100644 --- a/rijndael.cpp +++ b/rijndael.cpp @@ -1298,7 +1298,7 @@ size_t Rijndael::Enc::AdvancedProcessBlocks(const byte *inBlocks, const byte *xo return length; static const byte *zeros = (const byte*)(Te+256); - byte *space = NULL, *originalSpace = const_cast(m_aliasBlock.data()); + byte *space = NULLPTR, *originalSpace = const_cast(m_aliasBlock.data()); // round up to nearest 256 byte boundary space = originalSpace + (s_aliasBlockSize - (uintptr_t)originalSpace % s_aliasBlockSize) % s_aliasBlockSize; diff --git a/rng.cpp b/rng.cpp index 3414b906..44c81e15 100644 --- a/rng.cpp +++ b/rng.cpp @@ -76,7 +76,7 @@ X917RNG::X917RNG(BlockTransformation *c, const byte *seed, const byte *determini if (!deterministicTimeVector) { - time_t tstamp1 = time(0); + time_t tstamp1 = time(NULLPTR); xorbuf(m_datetime, (byte *)&tstamp1, UnsignedMin(sizeof(tstamp1), m_size)); m_cipher->ProcessBlock(m_datetime); clock_t tstamp2 = clock(); @@ -102,7 +102,7 @@ void X917RNG::GenerateIntoBufferedTransformation(BufferedTransformation &target, { clock_t c = clock(); xorbuf(m_datetime, (byte *)&c, UnsignedMin(sizeof(c), m_size)); - time_t t = time(NULL); + time_t t = time(NULLPTR); xorbuf(m_datetime+m_size-UnsignedMin(sizeof(t), m_size), (byte *)&t, UnsignedMin(sizeof(t), m_size)); m_cipher->ProcessBlock(m_datetime); } diff --git a/rng.h b/rng.h index 9833bf08..dc18cb48 100644 --- a/rng.h +++ b/rng.h @@ -62,9 +62,9 @@ public: //! SecByteBlock key(AES::DEFAULT_KEYLENGTH), seed(AES::BLOCKSIZE); //! OS_GenerateRandomBlock(false, key, key.size()); //! OS_GenerateRandomBlock(false, seed, seed.size()); - //! X917RNG prng(new AES::Encryption(key, AES::DEFAULT_KEYLENGTH), seed, NULL); + //! X917RNG prng(new AES::Encryption(key, AES::DEFAULT_KEYLENGTH), seed, NULLPTR); //! \sa AutoSeededX917RNG - X917RNG(BlockTransformation *cipher, const byte *seed, const byte *deterministicTimeVector = 0); + X917RNG(BlockTransformation *cipher, const byte *seed, const byte *deterministicTimeVector = NULLPTR); void GenerateIntoBufferedTransformation(BufferedTransformation &target, const std::string &channel, lword size); diff --git a/secblock.h b/secblock.h index 7ee41f61..6d2346ee 100644 --- a/secblock.h +++ b/secblock.h @@ -124,7 +124,7 @@ typename A::pointer StandardReallocate(A& alloc, T *oldPtr, typename A::size_typ if (preserve) { - typename A::pointer newPointer = alloc.allocate(newSize, NULL); + typename A::pointer newPointer = alloc.allocate(newSize, NULLPTR); const size_t copySize = STDMIN(oldSize, newSize) * sizeof(T); if (oldPtr && newPointer) {memcpy_s(newPointer, copySize, oldPtr, copySize);} @@ -134,7 +134,7 @@ typename A::pointer StandardReallocate(A& alloc, T *oldPtr, typename A::size_typ else { alloc.deallocate(oldPtr, oldSize); - return alloc.allocate(newSize, NULL); + return alloc.allocate(newSize, NULLPTR); } } @@ -168,12 +168,12 @@ public: //! \sa CallNewHandler() for the methods used to recover from a failed //! allocation attempt. //! \note size is the count of elements, and not the number of bytes - pointer allocate(size_type size, const void *ptr = NULL) + pointer allocate(size_type size, const void *ptr = NULLPTR) { - CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULL); + CRYPTOPP_UNUSED(ptr); CRYPTOPP_ASSERT(ptr == NULLPTR); this->CheckSize(size); if (size == 0) - return NULL; + return NULLPTR; #if CRYPTOPP_BOOL_ALIGN16 // TODO: should this need the test 'size*sizeof(T) >= 16'? @@ -291,10 +291,10 @@ public: // TODO: should this return NULL or throw bad_alloc? Non-Windows C++ standard // libraries always throw. And late mode Windows throws. Early model Windows // (circa VC++ 6.0) returned NULL. - pointer allocate(size_type n, const void* unused = NULL) + pointer allocate(size_type n, const void* unused = NULLPTR) { CRYPTOPP_UNUSED(n); CRYPTOPP_UNUSED(unused); - CRYPTOPP_ASSERT(false); return NULL; + CRYPTOPP_ASSERT(false); return NULLPTR; } void deallocate(void *p, size_type n) @@ -453,7 +453,7 @@ public: return oldPtr; } - pointer newPointer = allocate(newSize, NULL); + pointer newPointer = allocate(newSize, NULLPTR); if (preserve && newSize) { const size_t copySize = STDMIN(oldSize, newSize); @@ -498,13 +498,13 @@ public: //! \details The elements are not initialized. //! \note size is the count of elements, and not the number of bytes explicit SecBlock(size_type size=0) - : m_mark(SIZE_MAX/sizeof(T)), m_size(size), m_ptr(m_alloc.allocate(size, NULL)) { } + : m_mark(SIZE_MAX/sizeof(T)), m_size(size), m_ptr(m_alloc.allocate(size, NULLPTR)) { } //! \brief Copy construct a SecBlock from another SecBlock //! \param t the other SecBlock //! \throws std::bad_alloc SecBlock(const SecBlock &t) - : m_mark(t.m_mark), m_size(t.m_size), m_ptr(m_alloc.allocate(t.m_size, NULL)) { + : m_mark(t.m_mark), m_size(t.m_size), m_ptr(m_alloc.allocate(t.m_size, NULLPTR)) { CRYPTOPP_ASSERT((!t.m_ptr && !m_size) || (t.m_ptr && m_size)); if (t.m_ptr) {memcpy_s(m_ptr, m_size*sizeof(T), t.m_ptr, t.m_size*sizeof(T));} } @@ -518,7 +518,7 @@ public: //! Otherwise, the block is empty and not initialized. //! \note size is the count of elements, and not the number of bytes SecBlock(const T *ptr, size_type len) - : m_mark(SIZE_MAX/sizeof(T)), m_size(len), m_ptr(m_alloc.allocate(len, NULL)) { + : m_mark(SIZE_MAX/sizeof(T)), m_size(len), m_ptr(m_alloc.allocate(len, NULLPTR)) { CRYPTOPP_ASSERT((!m_ptr && !m_size) || (m_ptr && m_size)); if (ptr && m_ptr) memcpy_s(m_ptr, m_size*sizeof(T), ptr, len*sizeof(T)); diff --git a/sha3.cpp b/sha3.cpp index 2c274fd4..6cfcaa67 100644 --- a/sha3.cpp +++ b/sha3.cpp @@ -245,7 +245,7 @@ static void KeccakF1600(word64 *state) } //copyToState(state, A) - Block::Put(NULL, state)(Aba)(Abe)(Abi)(Abo)(Abu)(Aga)(Age)(Agi)(Ago)(Agu)(Aka)(Ake)(Aki)(Ako)(Aku)(Ama)(Ame)(Ami)(Amo)(Amu)(Asa)(Ase)(Asi)(Aso)(Asu); + Block::Put(NULLPTR, state)(Aba)(Abe)(Abi)(Abo)(Abu)(Aga)(Age)(Agi)(Ago)(Agu)(Aka)(Ake)(Aki)(Ako)(Aku)(Ama)(Ame)(Ami)(Amo)(Amu)(Asa)(Ase)(Asi)(Aso)(Asu); } } diff --git a/simple.h b/simple.h index 7b0e8ca6..2b92d343 100644 --- a/simple.h +++ b/simple.h @@ -262,7 +262,7 @@ public: // void ChannelMessageSeriesEnd(const std::string &channel, int propagation=-1) // {PropagateMessageSeriesEnd(propagation, channel);} byte * ChannelCreatePutSpace(const std::string &channel, size_t &size) - {CRYPTOPP_UNUSED(channel); size = 0; return NULL;} + {CRYPTOPP_UNUSED(channel); size = 0; return NULLPTR;} bool ChannelPutModifiable(const std::string &channel, byte *inString, size_t length) {this->ChannelPut(channel, inString, length); return false;} diff --git a/siphash.h b/siphash.h index c0b0014a..5e4f2f98 100644 --- a/siphash.h +++ b/siphash.h @@ -142,7 +142,7 @@ class SipHash : public SipHash_Base public: //! \brief Create a SipHash SipHash() - {this->UncheckedSetKey(NULL, 0, g_nullNameValuePairs);} + {this->UncheckedSetKey(NULLPTR, 0, g_nullNameValuePairs);} //! \brief Create a SipHash //! \param key a byte array used to key the cipher //! \param length the size of the byte array, in bytes diff --git a/smartptr.h b/smartptr.h index 605be2ed..cc7874fb 100644 --- a/smartptr.h +++ b/smartptr.h @@ -20,11 +20,11 @@ NAMESPACE_BEGIN(CryptoPP) template class simple_ptr { public: - simple_ptr(T *p = NULL) : m_p(p) {} + simple_ptr(T *p = NULLPTR) : m_p(p) {} ~simple_ptr() { delete m_p; - *((volatile T**)&m_p) = NULL; + m_p = NULLPTR; } T *m_p; @@ -39,7 +39,7 @@ public: template class member_ptr { public: - explicit member_ptr(T *p = NULL) : m_p(p) {} + explicit member_ptr(T *p = NULLPTR) : m_p(p) {} ~member_ptr(); @@ -55,7 +55,7 @@ public: T* release() { T *old_p = m_p; - *((volatile T**)&m_p) = NULL; + m_p = NULLPTR; return old_p; } @@ -80,9 +80,9 @@ template class value_ptr : public member_ptr { public: value_ptr(const T &obj) : member_ptr(new T(obj)) {} - value_ptr(T *p = NULL) : member_ptr(p) {} + value_ptr(T *p = NULLPTR) : member_ptr(p) {} value_ptr(const value_ptr& rhs) - : member_ptr(rhs.m_p ? new T(*rhs.m_p) : NULL) {} + : member_ptr(rhs.m_p ? new T(*rhs.m_p) : NULLPTR) {} value_ptr& operator=(const value_ptr& rhs); bool operator==(const value_ptr& rhs) @@ -94,7 +94,7 @@ public: template value_ptr& value_ptr::operator=(const value_ptr& rhs) { T *old_p = this->m_p; - this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULL; + this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULLPTR; delete old_p; return *this; } @@ -109,9 +109,9 @@ template class clonable_ptr : public member_ptr { public: clonable_ptr(const T &obj) : member_ptr(obj.Clone()) {} - clonable_ptr(T *p = NULL) : member_ptr(p) {} + clonable_ptr(T *p = NULLPTR) : member_ptr(p) {} clonable_ptr(const clonable_ptr& rhs) - : member_ptr(rhs.m_p ? rhs.m_p->Clone() : NULL) {} + : member_ptr(rhs.m_p ? rhs.m_p->Clone() : NULLPTR) {} clonable_ptr& operator=(const clonable_ptr& rhs); }; @@ -119,7 +119,7 @@ public: template clonable_ptr& clonable_ptr::operator=(const clonable_ptr& rhs) { T *old_p = this->m_p; - this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULL; + this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULLPTR; delete old_p; return *this; } diff --git a/socketft.cpp b/socketft.cpp index 64a1f29c..d9e492a7 100644 --- a/socketft.cpp +++ b/socketft.cpp @@ -86,7 +86,7 @@ int inet_pton(int af, const char *src, void *dst) int size = sizeof(ss); - if (WSAStringToAddress(temp, af, NULL, (struct sockaddr *)&ss, &size) == 0) { + if (WSAStringToAddress(temp, af, NULLPTR, (struct sockaddr *)&ss, &size) == 0) { switch (af) { case AF_INET: *(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr; @@ -160,7 +160,7 @@ void Socket::CloseSocket() { #ifdef USE_WINDOWS_STYLE_SOCKETS # if defined(USE_WINDOWS8_API) - BOOL result = CancelIoEx((HANDLE) m_s, NULL); + BOOL result = CancelIoEx((HANDLE) m_s, NULLPTR); CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND)); CheckAndHandleError_int("closesocket", closesocket(m_s)); CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds @@ -184,7 +184,7 @@ void Socket::Bind(unsigned int port, const char *addr) memset(&sa, 0, sizeof(sa)); sa.sin_family = AF_INET; - if (addr == NULL) + if (addr == NULLPTR) sa.sin_addr.s_addr = htonl(INADDR_ANY); else { @@ -218,7 +218,7 @@ void Socket::Listen(int backlog) bool Socket::Connect(const char *addr, unsigned int port) { - CRYPTOPP_ASSERT(addr != NULL); + CRYPTOPP_ASSERT(addr != NULLPTR); sockaddr_in sa; memset(&sa, 0, sizeof(sa)); @@ -230,13 +230,13 @@ bool Socket::Connect(const char *addr, unsigned int port) if (sa.sin_addr.s_addr == INADDR_NONE) { - addrinfo hints, *result = NULL; + addrinfo hints, *result = NULLPTR; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; hints.ai_family = AF_INET; - if (getaddrinfo(addr, NULL, &hints, &result) != 0 || result == NULL) + if (getaddrinfo(addr, NULLPTR, &hints, &result) != 0 || result == NULLPTR) { freeaddrinfo(result); SetLastError(SOCKET_EINVAL); @@ -331,12 +331,12 @@ bool Socket::SendReady(const timeval *timeout) #endif int ready; - if (timeout == NULL) - ready = select((int)m_s+1, NULL, &fds, NULL, NULL); + if (timeout == NULLPTR) + ready = select((int)m_s+1, NULLPTR, &fds, NULLPTR, NULLPTR); else { timeval timeoutCopy = *timeout; // select() modified timeout on Linux - ready = select((int)m_s+1, NULL, &fds, NULL, &timeoutCopy); + ready = select((int)m_s+1, NULLPTR, &fds, NULLPTR, &timeoutCopy); } CheckAndHandleError_int("select", ready); return ready > 0; @@ -352,12 +352,12 @@ bool Socket::ReceiveReady(const timeval *timeout) #endif int ready; - if (timeout == NULL) - ready = select((int)m_s+1, &fds, NULL, NULL, NULL); + if (timeout == NULLPTR) + ready = select((int)m_s+1, &fds, NULLPTR, NULLPTR, NULLPTR); else { timeval timeoutCopy = *timeout; // select() modified timeout on Linux - ready = select((int)m_s+1, &fds, NULL, NULL, &timeoutCopy); + ready = select((int)m_s+1, &fds, NULLPTR, NULLPTR, &timeoutCopy); } CheckAndHandleError_int("select", ready); return ready > 0; @@ -423,7 +423,7 @@ void Socket::HandleError(const char *operation) const SocketReceiver::SocketReceiver(Socket &s) : m_s(s), m_lastResult(0), m_resultPending(false), m_eofReceived(false) { - m_event.AttachHandle(CreateEvent(NULL, true, false, NULL), true); + m_event.AttachHandle(CreateEvent(NULLPTR, true, false, NULLPTR), true); m_s.CheckAndHandleError("CreateEvent", m_event.HandleValid()); memset(&m_overlapped, 0, sizeof(m_overlapped)); m_overlapped.hEvent = m_event; @@ -433,7 +433,7 @@ SocketReceiver::~SocketReceiver() { #ifdef USE_WINDOWS_STYLE_SOCKETS # if defined(USE_WINDOWS8_API) - BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULL); + BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULLPTR); CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND)); CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds # else @@ -451,7 +451,7 @@ bool SocketReceiver::Receive(byte* buf, size_t bufLen) DWORD flags = 0; // don't queue too much at once, or we might use up non-paged memory WSABUF wsabuf = {UnsignedMin((u_long)128*1024, bufLen), (char *)buf}; - if (WSARecv(m_s, &wsabuf, 1, &m_lastResult, &flags, &m_overlapped, NULL) == 0) + if (WSARecv(m_s, &wsabuf, 1, &m_lastResult, &flags, &m_overlapped, NULLPTR) == 0) { if (m_lastResult == 0) m_eofReceived = true; @@ -514,7 +514,7 @@ unsigned int SocketReceiver::GetReceiveResult() SocketSender::SocketSender(Socket &s) : m_s(s), m_lastResult(0), m_resultPending(false) { - m_event.AttachHandle(CreateEvent(NULL, true, false, NULL), true); + m_event.AttachHandle(CreateEvent(NULLPTR, true, false, NULLPTR), true); m_s.CheckAndHandleError("CreateEvent", m_event.HandleValid()); memset(&m_overlapped, 0, sizeof(m_overlapped)); m_overlapped.hEvent = m_event; @@ -525,7 +525,7 @@ SocketSender::~SocketSender() { #ifdef USE_WINDOWS_STYLE_SOCKETS # if defined(USE_WINDOWS8_API) - BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULL); + BOOL result = CancelIoEx((HANDLE) m_s.GetSocket(), NULLPTR); CRYPTOPP_ASSERT(result || (!result && GetLastError() == ERROR_NOT_FOUND)); CRYPTOPP_UNUSED(result); // Used by CRYPTOPP_ASSERT in debug builds # else @@ -542,7 +542,7 @@ void SocketSender::Send(const byte* buf, size_t bufLen) DWORD written = 0; // don't queue too much at once, or we might use up non-paged memory WSABUF wsabuf = {UnsignedMin((u_long)128*1024, bufLen), (char *)buf}; - if (WSASend(m_s, &wsabuf, 1, &written, 0, &m_overlapped, NULL) == 0) + if (WSASend(m_s, &wsabuf, 1, &written, 0, &m_overlapped, NULLPTR) == 0) { m_resultPending = false; m_lastResult = written; diff --git a/socketft.h b/socketft.h index 0fefb65c..c9942d8e 100644 --- a/socketft.h +++ b/socketft.h @@ -70,14 +70,14 @@ public: void CloseSocket(); void Create(int nType = SOCK_STREAM); - void Bind(unsigned int port, const char *addr=NULL); + void Bind(unsigned int port, const char *addr=NULLPTR); void Bind(const sockaddr* psa, socklen_t saLen); void Listen(int backlog = SOMAXCONN); // the next three functions return false if the socket is in nonblocking mode // and the operation cannot be completed immediately bool Connect(const char *addr, unsigned int port); bool Connect(const sockaddr* psa, socklen_t saLen); - bool Accept(Socket& s, sockaddr *psa=NULL, socklen_t *psaLen=NULL); + bool Accept(Socket& s, sockaddr *psa=NULLPTR, socklen_t *psaLen=NULLPTR); void GetSockName(sockaddr *psa, socklen_t *psaLen); void GetPeerName(sockaddr *psa, socklen_t *psaLen); unsigned int Send(const byte* buf, size_t bufLen, int flags=0); @@ -194,7 +194,7 @@ private: class SocketSource : public NetworkSource, public Socket { public: - SocketSource(socket_t s = INVALID_SOCKET, bool pumpAll = false, BufferedTransformation *attachment = NULL) + SocketSource(socket_t s = INVALID_SOCKET, bool pumpAll = false, BufferedTransformation *attachment = NULLPTR) : NetworkSource(attachment), Socket(s), m_receiver(*this) { if (pumpAll) diff --git a/strciphr.h b/strciphr.h index 5da9166a..83be614c 100644 --- a/strciphr.h +++ b/strciphr.h @@ -133,7 +133,7 @@ struct CRYPTOPP_DLL CRYPTOPP_NO_VTABLE AdditiveCipherAbstractPolicy //! \param iterationCount the number of iterations to generate the key stream //! \sa CanOperateKeystream(), OperateKeystream(), WriteKeystream() virtual void WriteKeystream(byte *keystream, size_t iterationCount) - {OperateKeystream(KeystreamOperation(INPUT_NULL | (KeystreamOperationFlags)IsAlignedOn(keystream, GetAlignment())), keystream, NULL, iterationCount);} + {OperateKeystream(KeystreamOperation(INPUT_NULL | (KeystreamOperationFlags)IsAlignedOn(keystream, GetAlignment())), keystream, NULLPTR, iterationCount);} //! \brief Flag indicating //! \returns true if the stream can be generated independent of the transformation input, false otherwise @@ -423,7 +423,7 @@ struct CRYPTOPP_NO_VTABLE CFB_CipherConcretePolicy : public BASE bool CanIterate() const {return true;} //! \brief Perform one iteration in the forward direction - void TransformRegister() {this->Iterate(NULL, NULL, ENCRYPTION, 1);} + void TransformRegister() {this->Iterate(NULLPTR, NULLPTR, ENCRYPTION, 1);} //! \brief //! \tparam B enumeration indicating endianness @@ -449,9 +449,9 @@ struct CRYPTOPP_NO_VTABLE CFB_CipherConcretePolicy : public BASE if (m_dir == ENCRYPTION) { - if (m_input == NULL) + if (m_input == NULLPTR) { - CRYPTOPP_ASSERT(m_output == NULL); + CRYPTOPP_ASSERT(m_output == NULLPTR); } else { diff --git a/test.cpp b/test.cpp index 8ed82d54..bff38434 100644 --- a/test.cpp +++ b/test.cpp @@ -113,7 +113,7 @@ void FIPS140_GenerateRandomFiles(); bool Validate(int, bool, const char *); void PrintSeedAndThreads(const std::string& seed); -int (*AdhocTest)(int argc, char *argv[]) = NULL; +int (*AdhocTest)(int argc, char *argv[]) = NULLPTR; NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) @@ -153,7 +153,7 @@ int CRYPTOPP_API main(int argc, char *argv[]) RegisterFactories(); // Some editors have problems with the '\0' character when redirecting output. - std::string seed = IntToString(time(NULL)); + std::string seed = IntToString(time(NULLPTR)); seed.resize(16, ' '); // Fetch the SymmetricCipher interface, not the RandomNumberGenerator interface, to key the underlying cipher @@ -366,7 +366,7 @@ int CRYPTOPP_API main(int argc, char *argv[]) else if (command == "ir") InformationRecoverFile(argc-3, argv[2], argv+3); else if (command == "v" || command == "vv") - return !Validate(argc>2 ? Test::StringToValue(argv[2]) : 0, argv[1][1] == 'v', argc>3 ? argv[3] : NULL); + return !Validate(argc>2 ? Test::StringToValue(argv[2]) : 0, argv[1][1] == 'v', argc>3 ? argv[3] : NULLPTR); else if (command == "b") Test::BenchmarkAll(argc<3 ? 1 : Test::StringToValue(argv[2]), argc<4 ? 0.0f : Test::StringToValue(argv[3])*1e9); else if (command == "b2") @@ -657,7 +657,7 @@ void SecretShareFile(int threshold, int nShares, const char *filename, const cha RandomPool rng; rng.IncorporateEntropy((byte *)seed, strlen(seed)); - ChannelSwitch *channelSwitch = NULL; + ChannelSwitch *channelSwitch = NULLPTR; FileSource source(filename, false, new SecretSharing(rng, threshold, nShares, channelSwitch = new ChannelSwitch)); vector_member_ptrs fileSinks(nShares); @@ -711,7 +711,7 @@ void InformationDisperseFile(int threshold, int nShares, const char *filename) if (threshold < 1 || threshold > 1000) throw InvalidArgument("InformationDisperseFile: " + IntToString(nShares) + " is not in range [1, 1000]"); - ChannelSwitch *channelSwitch = NULL; + ChannelSwitch *channelSwitch = NULLPTR; FileSource source(filename, false, new InformationDispersal(threshold, nShares, channelSwitch = new ChannelSwitch)); vector_member_ptrs fileSinks(nShares); @@ -860,8 +860,8 @@ void ForwardTcpPort(const char *sourcePortName, const char *destinationHost, con { waitObjects.Clear(); - out.GetWaitObjects(waitObjects, CallStack("ForwardTcpPort - out", NULL)); - in.GetWaitObjects(waitObjects, CallStack("ForwardTcpPort - in", NULL)); + out.GetWaitObjects(waitObjects, CallStack("ForwardTcpPort - out", NULLPTR)); + in.GetWaitObjects(waitObjects, CallStack("ForwardTcpPort - in", NULLPTR)); waitObjects.Wait(INFINITE_TIME); @@ -893,7 +893,7 @@ bool Validate(int alg, bool thorough, const char *seedInput) // Some editors have problems with the '\0' character when redirecting output. // seedInput is argv[3] when issuing 'cryptest.exe v all ' - std::string seed = (seedInput ? seedInput : IntToString(time(NULL))); + std::string seed = (seedInput ? seedInput : IntToString(time(NULLPTR))); seed.resize(16, ' '); OFB_Mode::Encryption& prng = dynamic_cast::Encryption&>(Test::GlobalRNG()); @@ -1007,7 +1007,7 @@ bool Validate(int alg, bool thorough, const char *seedInput) char timeBuf[64]; errno_t err; - const time_t endTime = time(NULL); + const time_t endTime = time(NULLPTR); err = localtime_s(&localTime, &endTime); CRYPTOPP_ASSERT(err == 0); err = asctime_s(timeBuf, sizeof(timeBuf), &localTime); @@ -1015,7 +1015,7 @@ bool Validate(int alg, bool thorough, const char *seedInput) std::cout << "\nTest ended at " << timeBuf; #else - const time_t endTime = time(NULL); + const time_t endTime = time(NULLPTR); std::cout << "\nTest ended at " << asctime(localtime(&endTime)); #endif diff --git a/trdlocal.cpp b/trdlocal.cpp index a9b42bc6..beb21e98 100644 --- a/trdlocal.cpp +++ b/trdlocal.cpp @@ -35,7 +35,7 @@ ThreadLocalStorage::ThreadLocalStorage() throw Err("TlsAlloc", GetLastError()); #else m_index = 0; - int error = pthread_key_create(&m_index, NULL); + int error = pthread_key_create(&m_index, NULLPTR); CRYPTOPP_ASSERT(!error); if (error) throw Err("pthread_key_create", error); diff --git a/validat0.cpp b/validat0.cpp index ce1f226b..933f78ef 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -744,7 +744,7 @@ bool TestSecBlock() { // NULL ptr with a size means to create a new SecBlock with all elements zero'd - SecByteBlock z1(NULL, 256); + SecByteBlock z1(NULLPTR, 256); temp = true; for (size_t i = 0; i < z1.size(); i++) @@ -757,7 +757,7 @@ bool TestSecBlock() std::cout << "passed: "; std::cout << "Zeroized byte array" << std::endl; - SecBlock z2(NULL, 256); + SecBlock z2(NULLPTR, 256); temp = true; for (size_t i = 0; i < z2.size(); i++) @@ -770,7 +770,7 @@ bool TestSecBlock() std::cout << "passed: "; std::cout << "Zeroized word32 array" << std::endl; - SecBlock z3(NULL, 256); + SecBlock z3(NULLPTR, 256); temp = true; for (size_t i = 0; i < z3.size(); i++) @@ -784,7 +784,7 @@ bool TestSecBlock() std::cout << "Zeroized word64 array" << std::endl; #if defined(CRYPTOPP_WORD128_AVAILABLE) - SecBlock z4(NULL, 256); + SecBlock z4(NULLPTR, 256); temp = true; for (size_t i = 0; i < z4.size(); i++) @@ -802,17 +802,17 @@ bool TestSecBlock() //********** Non-zero'd block **********// { - SecByteBlock z1(NULL, 256); + SecByteBlock z1(NULLPTR, 256); z1.SetMark(0); - SecBlock z2(NULL, 256); + SecBlock z2(NULLPTR, 256); z2.SetMark(0); - SecBlock z3(NULL, 256); + SecBlock z3(NULLPTR, 256); z3.SetMark(0); #if defined(CRYPTOPP_WORD128_AVAILABLE) - SecBlock z4(NULL, 256); + SecBlock z4(NULLPTR, 256); z4.SetMark(0); #endif } diff --git a/validat1.cpp b/validat1.cpp index 06c8113d..df4369f0 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -376,7 +376,7 @@ bool TestOS_RNG() MeterFilter meter(new Redirector(TheBitBucket())); RandomNumberSource test(*rng, UINT_MAX, false, new Deflator(new Redirector(meter))); unsigned long total=0, length=0; - time_t t = time(NULL), t1 = 0; + time_t t = time(NULLPTR), t1 = 0; CRYPTOPP_UNUSED(length); // check that it doesn't take too long to generate a reasonable amount of randomness @@ -384,7 +384,7 @@ bool TestOS_RNG() { test.Pump(1); total += 1; - t1 = time(NULL) - t; + t1 = time(NULLPTR) - t; } if (total < 16) @@ -401,8 +401,8 @@ bool TestOS_RNG() { // that was fast, are we really blocking? // first exhaust the extropy reserve - t = time(NULL); - while (time(NULL) - t < 2) + t = time(NULLPTR); + while (time(NULLPTR) - t < 2) { test.Pump(1); total += 1; @@ -410,8 +410,8 @@ bool TestOS_RNG() // if it generates too many bytes in a certain amount of time, // something's probably wrong - t = time(NULL); - while (time(NULL) - t < 2) + t = time(NULLPTR); + while (time(NULLPTR) - t < 2) { test.Pump(1); total += 1; @@ -424,7 +424,7 @@ bool TestOS_RNG() } else std::cout << "passed:"; - std::cout << " it generated " << length << " bytes in " << long(time(NULL) - t) << " seconds" << std::endl; + std::cout << " it generated " << length << " bytes in " << long(time(NULLPTR) - t) << " seconds" << std::endl; } #endif @@ -442,7 +442,7 @@ bool TestOS_RNG() else std::cout << "\nNo operating system provided blocking random number generator, skipping test." << std::endl; - rng.reset(NULL); + rng.reset(NULLPTR); #ifdef NONBLOCKING_RNG_AVAILABLE try {rng.reset(new NonblockingRng);} catch (OS_RNG_Err &) {} @@ -678,7 +678,7 @@ bool TestRDRAND() (void)rdrand.AlgorithmName(); (void)rdrand.CanIncorporateEntropy(); rdrand.SetRetries(rdrand.GetRetries()); - rdrand.IncorporateEntropy(NULL, 0); + rdrand.IncorporateEntropy(NULLPTR, 0); if (!(entropy && compress && discard)) std::cout.flush(); @@ -757,7 +757,7 @@ bool TestRDSEED() (void)rdseed.AlgorithmName(); (void)rdseed.CanIncorporateEntropy(); rdseed.SetRetries(rdseed.GetRetries()); - rdseed.IncorporateEntropy(NULL, 0); + rdseed.IncorporateEntropy(NULLPTR, 0); if (!(entropy && compress && discard)) std::cout.flush(); @@ -1453,13 +1453,13 @@ bool ValidateCipherModes() 0x89, 0x3d, 0x51, 0xec, 0x4b, 0x56, 0x3b, 0x53}; ECB_Mode_ExternalCipher::Encryption modeE(desE); - fail = !TestFilter(StreamTransformationFilter(modeE, NULL, StreamTransformationFilter::NO_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeE, NULLPTR, StreamTransformationFilter::NO_PADDING).Ref(), plain, sizeof(plain), encrypted, sizeof(encrypted)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "ECB encryption" << std::endl; ECB_Mode_ExternalCipher::Decryption modeD(desD); - fail = !TestFilter(StreamTransformationFilter(modeD, NULL, StreamTransformationFilter::NO_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeD, NULLPTR, StreamTransformationFilter::NO_PADDING).Ref(), encrypted, sizeof(encrypted), plain, sizeof(plain)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "ECB decryption" << std::endl; @@ -1472,13 +1472,13 @@ bool ValidateCipherModes() 0x68, 0x37, 0x88, 0x49, 0x9A, 0x7C, 0x05, 0xF6}; CBC_Mode_ExternalCipher::Encryption modeE(desE, iv); - fail = !TestFilter(StreamTransformationFilter(modeE, NULL, StreamTransformationFilter::NO_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeE, NULLPTR, StreamTransformationFilter::NO_PADDING).Ref(), plain, sizeof(plain), encrypted, sizeof(encrypted)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "CBC encryption with no padding" << std::endl; CBC_Mode_ExternalCipher::Decryption modeD(desD, iv); - fail = !TestFilter(StreamTransformationFilter(modeD, NULL, StreamTransformationFilter::NO_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeD, NULLPTR, StreamTransformationFilter::NO_PADDING).Ref(), encrypted, sizeof(encrypted), plain, sizeof(plain)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "CBC decryption with no padding" << std::endl; @@ -1518,13 +1518,13 @@ bool ValidateCipherModes() 0xcf, 0xb7, 0xc7, 0x64, 0x0e, 0x7c, 0xd9, 0xa7}; CBC_Mode_ExternalCipher::Encryption modeE(desE, iv); - fail = !TestFilter(StreamTransformationFilter(modeE, NULL, StreamTransformationFilter::ONE_AND_ZEROS_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeE, NULLPTR, StreamTransformationFilter::ONE_AND_ZEROS_PADDING).Ref(), plain, sizeof(plain), encrypted, sizeof(encrypted)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "CBC encryption with one-and-zeros padding" << std::endl; CBC_Mode_ExternalCipher::Decryption modeD(desD, iv); - fail = !TestFilter(StreamTransformationFilter(modeD, NULL, StreamTransformationFilter::ONE_AND_ZEROS_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeD, NULLPTR, StreamTransformationFilter::ONE_AND_ZEROS_PADDING).Ref(), encrypted, sizeof(encrypted), plain, sizeof(plain)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "CBC decryption with one-and-zeros padding" << std::endl; @@ -1536,13 +1536,13 @@ bool ValidateCipherModes() 0x9B, 0x47, 0x57, 0x59, 0xD6, 0x9C, 0xF6, 0xD0}; CBC_Mode_ExternalCipher::Encryption modeE(desE, iv); - fail = !TestFilter(StreamTransformationFilter(modeE, NULL, StreamTransformationFilter::ZEROS_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeE, NULLPTR, StreamTransformationFilter::ZEROS_PADDING).Ref(), plain_1, 1, encrypted, sizeof(encrypted)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "CBC encryption with zeros padding" << std::endl; CBC_Mode_ExternalCipher::Decryption modeD(desD, iv); - fail = !TestFilter(StreamTransformationFilter(modeD, NULL, StreamTransformationFilter::ZEROS_PADDING).Ref(), + fail = !TestFilter(StreamTransformationFilter(modeD, NULLPTR, StreamTransformationFilter::ZEROS_PADDING).Ref(), encrypted, sizeof(encrypted), plain_1, sizeof(plain_1)); pass = pass && !fail; std::cout << (fail ? "FAILED " : "passed ") << "CBC decryption with zeros padding" << std::endl; diff --git a/validat2.cpp b/validat2.cpp index d37c2c4b..0a2818e0 100644 --- a/validat2.cpp +++ b/validat2.cpp @@ -152,9 +152,9 @@ bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough = false) if (priv.MaxRecoverableLength() > 0) { - signatureLength = priv.SignMessageWithRecovery(GlobalRNG(), message, messageLen, NULL, 0, signature); + signatureLength = priv.SignMessageWithRecovery(GlobalRNG(), message, messageLen, NULLPTR, 0, signature); SecByteBlock recovered(priv.MaxRecoverableLengthFromSignatureLength(signatureLength)); - DecodingResult result = pub.RecoverMessage(recovered, NULL, 0, signature, signatureLength); + DecodingResult result = pub.RecoverMessage(recovered, NULLPTR, 0, signature, signatureLength); fail = !(result.isValidCoding && result.messageLength == messageLen && memcmp(recovered, message, messageLen) == 0); pass = pass && !fail; @@ -162,7 +162,7 @@ bool SignatureValidate(PK_Signer &priv, PK_Verifier &pub, bool thorough = false) std::cout << "signature and verification with recovery" << std::endl; ++signature[0]; - result = pub.RecoverMessage(recovered, NULL, 0, signature, signatureLength); + result = pub.RecoverMessage(recovered, NULLPTR, 0, signature, signatureLength); fail = result.isValidCoding; pass = pass && !fail; diff --git a/validat3.cpp b/validat3.cpp index 6df1b91d..2ff56541 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -662,8 +662,8 @@ bool TestHKDF(KeyDerivationFunction &kdf, const HKDF_TestTuple *testSet, unsigne SecByteBlock derived(expected.size()); unsigned int ret = kdf.DeriveKey(derived, derived.size(), reinterpret_cast(secret.data()), secret.size(), - (tuple.hexSalt ? reinterpret_cast(salt.data()) : NULL), salt.size(), - (tuple.hexInfo ? reinterpret_cast(info.data()) : NULL), info.size()); + (tuple.hexSalt ? reinterpret_cast(salt.data()) : NULLPTR), salt.size(), + (tuple.hexInfo ? reinterpret_cast(info.data()) : NULLPTR), info.size()); bool fail = !VerifyBufsEqual(derived, reinterpret_cast(expected.data()), derived.size()); pass = pass && (ret == tuple.len) && !fail; @@ -697,7 +697,7 @@ bool ValidateHKDF() // Test Case #6 {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "0ac1af7002b3d761d1e55298da9d0506 b9ae52057220a306e07b6b87e8df21d0 ea00033de03984d34918", 42}, // Test Case #7 - {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c", NULL, "", "2c91117204d745f3500d636a62f64f0 ab3bae548aa53d423b0d1f27ebba6f5e5 673a081d70cce7acfc48", 42} + {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c", NULLPTR, "", "2c91117204d745f3500d636a62f64f0 ab3bae548aa53d423b0d1f27ebba6f5e5 673a081d70cce7acfc48", 42} }; HKDF hkdf; @@ -735,7 +735,7 @@ bool ValidateHKDF() // Test Case #0 {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "F5FA02B18298A72A8C23898A8703472C 6EB179DC204C03425C970E3B164BF90F FF22D04836D0E2343BAC", 42}, // Test Case #0 - {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c", NULL, "", "1407D46013D98BC6DECEFCFEE55F0F90 B0C7F63D68EB1A80EAF07E953CFC0A3A 5240A155D6E4DAA965BB", 42} + {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c", NULLPTR, "", "1407D46013D98BC6DECEFCFEE55F0F90 B0C7F63D68EB1A80EAF07E953CFC0A3A 5240A155D6E4DAA965BB", 42} }; HKDF hkdf; @@ -757,7 +757,7 @@ bool ValidateHKDF() // Test Case #0 {"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b", "", "", "110632D0F7AEFAC31771FC66C22BB346 2614B81E4B04BA7F2B662E0BD694F564 58615F9A9CB56C57ECF2", 42}, // Test Case #0 - {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" /*key*/, NULL /*salt*/, "" /*info*/, "4089286EBFB23DD8A02F0C9DAA35D538 EB09CD0A8CBAB203F39083AA3E0BD313 E6F91E64F21A187510B0", 42} + {"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c" /*key*/, NULLPTR /*salt*/, "" /*info*/, "4089286EBFB23DD8A02F0C9DAA35D538 EB09CD0A8CBAB203F39083AA3E0BD313 E6F91E64F21A187510B0", 42} }; HKDF hkdf; @@ -766,7 +766,6 @@ bool ValidateHKDF() pass = TestHKDF(hkdf, testSet, COUNTOF(testSet)) && pass; } - return pass; } @@ -1087,68 +1086,68 @@ bool ValidateBLAKE2s() static const BLAKE2_TestTuples tests[] = { { - NULL, - NULL, + NULLPTR, + NULLPTR, "\x69\x21\x7A\x30\x79\x90\x80\x94\xE1\x11\x21\xD0\x42\x35\x4A\x7C\x1F\x55\xB6\x48\x2C\xA1\xA5\x1E\x1B\x25\x0D\xFD\x1E\xD0\xEE\xF9", 0, 0, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x25\xEC\xB2\xF6\xA7\x81\x82\x57\x5D\x4B\xD7\x02\x72\x6D\xE1\x82\xBB\x1E\x21\xA8\x5D\x51\x34\xAD\xA2\x25\x8D\x7E\x21\x38\x03\xA7", 0, 15, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xD4\x1C\x69\x87\x29\x7E\xDE\x4F\x08\x9B\x66\x9B\xC7\x0E\x62\xB9\xFA\xFA\x1C\x37\xCC\x31\x29\x22\xE0\xEA\x63\xE2\xE5\x85\xAA\x9F", 0, 16, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xE0\xAD\xF2\xCC\x1F\x1F\x55\x3A\xE6\xC3\xCD\x3D\xF7\x68\xEA\x66\x9C\x32\xBE\x1D\x37\xF9\xA2\x61\xD4\x4F\x45\x26\x69\xD0\xD3\xA4", 0, 17, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x10\x42\x65\x1C\x86\x15\xC4\x87\x69\x41\x19\x1F\xB6\xD5\xC5\x1D\xEB\x4C\xA1\x8C\xAF\xEF\xEB\x79\x69\x62\x87\x0D\x6A\x5D\xEE\x20", 0, 31, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xEA\xB1\xC5\xDD\xDF\xB5\x7C\x48\xC5\xB0\xB3\xF5\xBE\x5B\x47\x6D\xBB\xF5\xA3\x5C\x21\xD3\xDD\x94\x13\xA1\x04\xB8\x14\xF9\x2D\x4B", 0, 32, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x7E\x82\x07\x49\x14\x62\x11\x96\xC5\xE8\xF3\xCB\x0F\x21\x7B\x37\xAE\x9B\x64\x58\xF4\x66\x01\xB9\x21\x23\xAC\x48\x64\x30\x83\x8F", 0, 33, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x90\xB5\xA2\x5E\x8E\xA8\xA0\xC8\x74\x85\xAE\x18\x08\x9D\x92\xEB\x14\x5A\x5D\x4E\x2C\x60\x7B\xCB\x4B\x94\xD1\x0F\xAE\x59\x33\xC1", 0, 63, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x71\x27\x28\x45\x9E\x67\xD7\xED\xB7\xAE\xFA\x88\xFF\x5C\x7E\x7B\x5D\xA9\x94\xA1\xC3\xB1\x7B\x64\xFB\xC1\x4E\x47\xCA\xDA\x45\xDD", 0, 64, 32 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x58\x72\x3B\xB1\xBE\x18\x33\x12\x31\x5E\x6E\xF7\xF2\xB1\x84\x60\x97\x2C\x19\xD3\x01\xAF\x42\x00\xAB\xDB\x04\x26\xFC\xB0\xC1\xF8", 0, 65, 32 }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x9A\xD4\x81\xEF\x81\x6C\xAC\xB6\x59\x35\x8E\x6D\x6B\x73\xF1\xE5\xAC\x71\xD6\x6E\x8B\x12\x6B\x73\xD9\xD9\x7D\x2F\xA7\xA4\x61\xB4", 15, 0, 32 }, @@ -1208,7 +1207,7 @@ bool ValidateBLAKE2s() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\xFD\x61\x6D\xA6\x8E\xEF\x10\x24\x16\xC7\xBD\x7D\xC8\xCA\xF8\x2B\x3D\x92\x7B\xCB\xDD\x06\x8E\x7C\xCA\xA7\x72\x76\xCE\x6C\x8C\xD4", 16, 0, 32 }, @@ -1268,7 +1267,7 @@ bool ValidateBLAKE2s() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\xD0\xCE\x8E\x8D\xA0\xBA\xA4\x26\x0E\xD3\x1F\xD1\x7B\x78\xE6\x18\x15\xC6\xFF\xD8\x5A\xDB\x41\x8A\xE7\x36\xF0\xE7\xB9\x87\x2B\x6A", 17, 0, 32 }, @@ -1328,7 +1327,7 @@ bool ValidateBLAKE2s() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x39\x4A\xB9\x85\xDD\xFF\x59\x59\x84\x5A\xF7\x54\xD6\xFC\x19\xFB\x94\x0E\xAE\xA4\xEA\x70\x54\x3E\x0D\x7E\x9D\xC7\x8A\x22\x77\x3B", 31, 0, 32 }, @@ -1388,7 +1387,7 @@ bool ValidateBLAKE2s() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x18\xE3\xCE\x19\x98\x7B\xA5\x0B\x30\xDD\x14\x4C\x16\xF2\x26\x55\xEB\xA3\x14\x09\xD6\x62\x10\xBC\x38\xBB\xC1\x4B\x5D\xAB\x05\x19", 32, 0, 32 }, @@ -1482,68 +1481,68 @@ bool ValidateBLAKE2b() static const BLAKE2_TestTuples tests[] = { { - NULL, - NULL, + NULLPTR, + NULLPTR, "\x78\x6A\x02\xF7\x42\x01\x59\x03\xC6\xC6\xFD\x85\x25\x52\xD2\x72\x91\x2F\x47\x40\xE1\x58\x47\x61\x8A\x86\xE2\x17\xF7\x1F\x54\x19\xD2\x5E\x10\x31\xAF\xEE\x58\x53\x13\x89\x64\x44\x93\x4E\xB0\x4B\x90\x3A\x68\x5B\x14\x48\xB7\x55\xD5\x6F\x70\x1A\xFE\x9B\xE2\xCE", 0, 0, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x2A\xF7\xA1\x34\x71\x1C\x5A\x03\xCE\xC8\xFC\xA9\x88\xD9\x9C\x8B\x99\x9A\x95\x33\x0D\xC9\x37\xBE\xE3\x3B\xB3\x0B\xAD\x1B\xE3\x7E\x4F\x66\x81\xF1\xE8\x0E\x64\xA1\x9D\xFC\x86\x83\xF1\xFE\x32\x5D\xAA\xDD\xB8\x1B\xA7\xA3\x88\x3F\x71\x1F\x04\x14\x08\x91\x16\x39", 0, 31, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x49\x9A\x63\x97\x86\x14\xB9\x50\xCC\x1D\xA0\xAB\x63\xAF\x3B\xC3\xFF\xBC\x63\xA2\x91\xE5\x2A\xD7\xA8\x11\xD6\xD4\x23\x32\x52\xCF\xA9\xD6\x5A\x19\x51\xBA\x20\xF1\x74\xEF\x7D\x82\x38\xFB\x85\x20\x82\x16\x0B\xC7\x3C\xD0\xD2\x72\x45\x75\x38\x5C\xE4\x17\xB1\xAA", 0, 32, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xA5\x5B\x85\xDD\x70\x10\xE5\x04\xD3\xB5\x10\xEF\x08\xE1\x95\x40\x19\x69\x82\x87\x44\xFD\xBF\x5B\xE8\xE2\xBB\xE3\x57\x8F\x24\x0B\xFB\x92\xD1\x50\x98\xAC\x06\xED\xC2\xBB\x93\x04\x54\x84\x35\x23\x83\xA1\xB0\x47\x91\x99\x0C\x4C\xA6\xFD\x73\x8D\xE5\x78\xA5\x5E", 0, 33, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xB8\xBC\xDA\xB9\x66\xE2\x5A\x76\x72\x38\x55\xD9\x5A\x4E\x8C\x4F\xA9\xEC\x8C\xFF\x0B\x18\x38\x98\x5C\x8C\x90\xBC\x46\x56\x24\xD7\x96\xAB\x26\x2B\x49\x14\xD0\xEE\x91\x69\x9A\x0C\xC3\xE6\xCA\x14\x55\x37\xDA\xF6\x59\x4A\x31\x78\x67\x49\x89\x0E\x84\xDC\xE7\x5D", 0, 63, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xA1\xD7\x6B\x3B\xB7\xCE\x56\x22\xD1\x13\x94\xDF\xF4\xA2\x04\xEF\x75\x85\xAF\x93\x63\x55\xBF\xCE\xAF\x01\x25\xCA\x17\x65\xC3\xD2\x6E\x67\x71\x95\x33\x18\xE7\xE4\xC1\xFA\xE0\xE6\x24\x8A\xE9\x56\xB7\x63\xE2\xBF\x8F\xB3\xA7\xD4\xD7\xFD\x1A\xC1\xAB\x1F\x17\x77", 0, 64, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xF3\x26\x82\x25\x97\xE1\x91\x53\xF8\x57\xC6\xD9\x57\x46\x09\xDF\x1E\x05\x81\xF6\x23\xEE\x8B\xBC\xFA\xA1\x9F\x21\xB6\xF3\x1D\xAD\x9F\x4E\x47\x0B\xE6\x3C\x5E\x28\xE9\x11\x1D\xAA\x52\xF2\x6B\x1A\x61\xCF\x61\x1C\xB0\x7D\xE5\x79\x14\x79\x79\xA6\x08\xDF\x76\x4B", 0, 65, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\x6A\x3F\x90\x50\x84\x5D\x84\xB7\xA2\x43\xF3\xEE\x2C\x7A\x10\x50\xC4\x4C\x5E\x39\xF4\xB8\xCC\x1D\xB3\xF1\x39\x82\x77\x22\x10\x92\x36\x21\xA0\xBA\x13\xCC\x4F\xA3\x1C\x4F\xEC\x1A\x15\x29\x20\x20\x3E\x1A\x06\xEA\xF4\xFF\xCB\x44\x72\x52\x3B\xE5\xE0\x08\x79\x92", 0, 127, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xC2\xB8\x8C\x5F\xBD\x61\x0F\xAB\x04\xD3\x40\xAD\x88\x74\x02\x6B\x27\x33\x5C\x6F\x8C\xE5\x93\xC3\x2F\x1A\xE5\xE8\x42\xA6\x07\xCB\xB7\x73\x88\xF3\xF5\xFF\xDC\xBF\xCC\x87\x8F\x56\x1F\xF2\x30\x37\x02\xBE\xC3\x1D\xA7\x8F\x12\x56\x35\x03\x50\xC6\x1E\xD8\xBD\x84", 0, 128, 64 }, { - NULL, + NULLPTR, "\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A\x7A", "\xAD\xE2\x77\xD8\x19\xA7\xBE\xF1\x4E\x47\x92\xDF\x4B\xFD\x1E\x7B\xDE\xC8\x41\x54\x31\xF6\x18\x79\x8B\x7F\x9A\x23\x3C\x6F\xA0\x56\xE6\xB3\x85\xBE\x76\x78\x88\x58\x86\x47\xEB\x48\xC5\x20\x62\xF3\x40\xA5\xB2\xB3\x3F\x33\x18\x3A\x12\xA8\xE9\x9A\x74\x9B\xE8\x8F", 0, 129, 64 }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x55\xD9\xFB\xF8\x8E\x42\x80\xBF\xE2\x75\xB8\xA7\xA1\xFA\xAD\x7D\xEA\x4B\x65\xB3\xDF\xA2\x92\xE1\xB0\x43\xB6\x36\x74\xB4\xC7\x87\x5D\x68\x02\x21\x39\x49\x0B\x69\x70\xC8\x80\x14\x82\x26\x77\x3D\x2D\x97\xAD\x01\x67\x55\x7D\x54\x62\xA0\x88\x0C\xB3\xFA\x69\x85", 31, 0, 64 }, @@ -1603,7 +1602,7 @@ bool ValidateBLAKE2b() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x0C\xAB\xE4\x02\x57\xEB\xAC\x85\xBC\xD6\x13\xBD\x40\x56\x58\xEC\x0B\x7F\x32\xB4\xDB\xBE\x6A\x31\x57\x60\x25\xC4\xFA\xBB\x3E\xDB\x55\x63\xE8\xD1\x27\x19\xB9\xEE\x9C\x7B\xE0\x0D\x8F\x09\xA4\x66\x5C\x32\x34\x34\xC8\x7F\x66\x00\xB7\x0B\x7B\x9C\x32\x74\xFC\x40", 32, 0, 64 }, @@ -1663,7 +1662,7 @@ bool ValidateBLAKE2b() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x0D\x19\x8F\xB3\x01\xE3\x83\x7D\xF1\xB9\x98\xEE\x48\x47\xF5\x1D\x91\x01\xEB\x91\x4A\x85\xFA\x6A\x7E\xBA\x7C\xDB\x12\x69\x45\xD7\x15\x6F\xF2\xF5\x05\x81\x27\xA0\x4A\xE4\xE8\xCF\x43\xD8\x76\x8A\x64\xFE\x9D\x97\x61\xE1\x0B\xC1\xBE\x45\xF9\xFA\x1C\xEB\x4B\xB6", 33, 0, 64 }, @@ -1723,7 +1722,7 @@ bool ValidateBLAKE2b() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\x31\xD7\x85\x5E\xBC\xAA\x40\xE2\xEF\xA6\xD4\x35\xC7\x9E\x37\x1E\x80\xBD\x1E\x37\x72\xE6\xEF\xD6\xB1\x41\x1A\xE5\xF8\xB2\x92\x1A\xE0\xAD\x11\xBF\xF0\x57\xD5\x9A\xF8\xC4\x4C\x11\x88\x64\xDA\x88\x45\x3C\xCC\xF7\xCB\x44\x9E\x34\x23\xA3\x9D\x6D\x11\x98\x0B\xAC", 63, 0, 64 }, @@ -1783,7 +1782,7 @@ bool ValidateBLAKE2b() }, { "\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61\x61", - NULL, + NULLPTR, "\xD9\x38\xD6\xD9\x8F\x0B\xD9\x87\x39\xA6\x59\x19\xD2\xB3\xC9\x14\x9A\x4F\xCE\x6C\x98\xB0\x6A\xF4\xF9\x58\x58\x31\x35\x0B\x57\x47\xC2\xF6\xA7\x82\xA3\x39\x61\xA8\x1B\x62\x59\x7A\x2E\xB1\xE9\xC0\xA5\x80\x3D\xA7\xC5\xD3\x93\x4B\xB2\x0A\x6E\x88\xBA\xA4\xAE\x02", 64, 0, 64 }, diff --git a/vmac.cpp b/vmac.cpp index 0256cbc8..30eee34d 100644 --- a/vmac.cpp +++ b/vmac.cpp @@ -76,7 +76,7 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con /* Fill nh key */ in[0] = 0x80; - cipher.AdvancedProcessBlocks(in, NULL, (byte *)m_nhKey(), m_nhKeySize()*sizeof(word64), cipher.BT_InBlockIsCounter); + cipher.AdvancedProcessBlocks(in, NULLPTR, (byte *)m_nhKey(), m_nhKeySize()*sizeof(word64), cipher.BT_InBlockIsCounter); ConditionalByteReverse(BIG_ENDIAN_ORDER, m_nhKey(), m_nhKey(), m_nhKeySize()*sizeof(word64)); /* Fill poly key */ diff --git a/vmac.h b/vmac.h index de95a5e5..535e2075 100644 --- a/vmac.h +++ b/vmac.h @@ -44,7 +44,7 @@ protected: void HashEndianCorrectedBlock(const word64 *data); size_t HashMultipleBlocks(const word64 *input, size_t length); void Init() {} - word64* StateBuf() {return NULL;} + word64* StateBuf() {return NULLPTR;} word64* DataBuf() {return (word64 *)(void*)m_data();} void VHASH_Update_SSE2(const word64 *data, size_t blocksRemainingInWord64, int tagPart); diff --git a/wait.cpp b/wait.cpp index a50d9f85..c6a74d94 100644 --- a/wait.cpp +++ b/wait.cpp @@ -248,8 +248,8 @@ void WaitObjectContainer::CreateThreads(unsigned int count) size_t currentCount = m_threads.size(); if (currentCount == 0) { - m_startWaiting = ::CreateEvent(NULL, TRUE, FALSE, NULL); - m_stopWaiting = ::CreateEvent(NULL, TRUE, FALSE, NULL); + m_startWaiting = ::CreateEvent(NULLPTR, TRUE, FALSE, NULLPTR); + m_stopWaiting = ::CreateEvent(NULLPTR, TRUE, FALSE, NULLPTR); } if (currentCount < count) @@ -266,7 +266,7 @@ void WaitObjectContainer::CreateThreads(unsigned int count) thread.startWaiting = m_startWaiting; thread.stopWaiting = m_stopWaiting; thread.waitingToWait = false; - thread.threadHandle = CreateThread(NULL, 0, &WaitingThread, &thread, 0, &thread.threadId); + thread.threadHandle = CreateThread(NULLPTR, 0, &WaitingThread, &thread, 0, &thread.threadId); } } } @@ -434,7 +434,7 @@ bool WaitObjectContainer::Wait(unsigned long milliseconds) timeval tv, *timeout; if (milliseconds == INFINITE_TIME) - timeout = NULL; + timeout = NULLPTR; else { tv.tv_sec = milliseconds / 1000; @@ -442,7 +442,7 @@ bool WaitObjectContainer::Wait(unsigned long milliseconds) timeout = &tv; } - int result = select(m_maxFd+1, &m_readfds, &m_writefds, NULL, timeout); + int result = select(m_maxFd+1, &m_readfds, &m_writefds, NULLPTR, timeout); if (result > 0) return true; diff --git a/wait.h b/wait.h index 4e51589f..c1cbddd5 100644 --- a/wait.h +++ b/wait.h @@ -178,7 +178,7 @@ public: static unsigned int MaxWaitObjects(); - WaitObjectContainer(WaitObjectsTracer* tracer = 0); + WaitObjectContainer(WaitObjectsTracer* tracer = NULLPTR); void Clear(); void SetNoWait(CallStack const& callStack); diff --git a/winpipes.cpp b/winpipes.cpp index b477673d..2585dd55 100644 --- a/winpipes.cpp +++ b/winpipes.cpp @@ -91,7 +91,7 @@ WindowsPipe::Err::Err(HANDLE s, const std::string& operation, int error) WindowsPipeReceiver::WindowsPipeReceiver() : m_lastResult(0), m_resultPending(false), m_eofReceived(false) { - m_event.AttachHandle(CreateEvent(NULL, true, false, NULL), true); + m_event.AttachHandle(CreateEvent(NULLPTR, true, false, NULLPTR), true); CheckAndHandleError("CreateEvent", m_event.HandleValid()); memset(&m_overlapped, 0, sizeof(m_overlapped)); m_overlapped.hEvent = m_event; @@ -172,7 +172,7 @@ unsigned int WindowsPipeReceiver::GetReceiveResult() WindowsPipeSender::WindowsPipeSender() : m_lastResult(0), m_resultPending(false) { - m_event.AttachHandle(CreateEvent(NULL, true, false, NULL), true); + m_event.AttachHandle(CreateEvent(NULLPTR, true, false, NULLPTR), true); CheckAndHandleError("CreateEvent", m_event.HandleValid()); memset(&m_overlapped, 0, sizeof(m_overlapped)); m_overlapped.hEvent = m_event; diff --git a/winpipes.h b/winpipes.h index 0ae0cc95..61fabdf1 100644 --- a/winpipes.h +++ b/winpipes.h @@ -109,7 +109,7 @@ private: class WindowsPipeSource : public WindowsHandle, public NetworkSource, public WindowsPipeReceiver { public: - WindowsPipeSource(HANDLE h=INVALID_HANDLE_VALUE, bool pumpAll=false, BufferedTransformation *attachment=NULL) + WindowsPipeSource(HANDLE h=INVALID_HANDLE_VALUE, bool pumpAll=false, BufferedTransformation *attachment=NULLPTR) : WindowsHandle(h), NetworkSource(attachment) { if (pumpAll) diff --git a/zdeflate.cpp b/zdeflate.cpp index a4b8e786..24576b9f 100644 --- a/zdeflate.cpp +++ b/zdeflate.cpp @@ -538,7 +538,7 @@ size_t Deflator::Put2(const byte *str, size_t length, int messageEnd, bool block Reset(); } - Output(0, NULL, 0, messageEnd, blocking); + Output(0, NULLPTR, 0, messageEnd, blocking); return 0; } diff --git a/zdeflate.h b/zdeflate.h index 07a10e60..e9c51b1c 100644 --- a/zdeflate.h +++ b/zdeflate.h @@ -104,12 +104,12 @@ public: //! \details detectUncompressible makes it faster to process uncompressible files, but //! if a file has both compressible and uncompressible parts, it may fail to compress //! some of the compressible parts. - Deflator(BufferedTransformation *attachment=NULL, int deflateLevel=DEFAULT_DEFLATE_LEVEL, int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true); + Deflator(BufferedTransformation *attachment=NULLPTR, int deflateLevel=DEFAULT_DEFLATE_LEVEL, int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true); //! \brief Construct a Deflator compressor //! \param parameters a set of NameValuePairs to initialize this object //! \param attachment an attached transformation //! \details Possible parameter names: Log2WindowSize, DeflateLevel, DetectUncompressible - Deflator(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULL); + Deflator(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULLPTR); //! \brief Sets the deflation level //! \param deflateLevel the level of deflation diff --git a/zinflate.cpp b/zinflate.cpp index c40a5883..6d8c31e7 100644 --- a/zinflate.cpp +++ b/zinflate.cpp @@ -309,7 +309,7 @@ size_t Inflator::Put2(const byte *inString, size_t length, int messageEnd, bool if (!(m_state == PRE_STREAM || m_state == AFTER_END)) throw UnexpectedEndErr(); - Output(0, NULL, 0, messageEnd, blocking); + Output(0, NULLPTR, 0, messageEnd, blocking); return 0; } @@ -359,7 +359,7 @@ void Inflator::ProcessInput(bool flush) return; ProcessPoststreamTail(); m_state = m_repeat ? PRE_STREAM : AFTER_END; - Output(0, NULL, 0, GetAutoSignalPropagation(), true); // TODO: non-blocking + Output(0, NULLPTR, 0, GetAutoSignalPropagation(), true); // TODO: non-blocking if (m_inQueue.IsEmpty()) return; break; diff --git a/zinflate.h b/zinflate.h index 26017261..b0879cef 100644 --- a/zinflate.h +++ b/zinflate.h @@ -105,7 +105,7 @@ public: //! \param attachment the filter's attached transformation //! \param repeat decompress multiple compressed streams in series //! \param autoSignalPropagation 0 to turn off MessageEnd signal - Inflator(BufferedTransformation *attachment = NULL, bool repeat = false, int autoSignalPropagation = -1); + Inflator(BufferedTransformation *attachment = NULLPTR, bool repeat = false, int autoSignalPropagation = -1); void IsolatedInitialize(const NameValuePairs ¶meters); size_t Put2(const byte *inString, size_t length, int messageEnd, bool blocking); diff --git a/zlib.h b/zlib.h index 258d06b5..b8e87f99 100644 --- a/zlib.h +++ b/zlib.h @@ -12,9 +12,9 @@ NAMESPACE_BEGIN(CryptoPP) class ZlibCompressor : public Deflator { public: - ZlibCompressor(BufferedTransformation *attachment=NULL, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true) + ZlibCompressor(BufferedTransformation *attachment=NULLPTR, unsigned int deflateLevel=DEFAULT_DEFLATE_LEVEL, unsigned int log2WindowSize=DEFAULT_LOG2_WINDOW_SIZE, bool detectUncompressible=true) : Deflator(attachment, deflateLevel, log2WindowSize, detectUncompressible) {} - ZlibCompressor(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULL) + ZlibCompressor(const NameValuePairs ¶meters, BufferedTransformation *attachment=NULLPTR) : Deflator(parameters, attachment) {} unsigned int GetCompressionLevel() const; @@ -41,7 +41,7 @@ public: //! \param attachment a \ BufferedTransformation to attach to this object //! \param repeat decompress multiple compressed streams in series //! \param autoSignalPropagation 0 to turn off MessageEnd signal - ZlibDecompressor(BufferedTransformation *attachment = NULL, bool repeat = false, int autoSignalPropagation = -1); + ZlibDecompressor(BufferedTransformation *attachment = NULLPTR, bool repeat = false, int autoSignalPropagation = -1); unsigned int GetLog2WindowSize() const {return m_log2WindowSize;} private: