diff --git a/algparam.h b/algparam.h index ca5f2c4a..bed8a6b3 100644 --- a/algparam.h +++ b/algparam.h @@ -191,7 +191,7 @@ public: if (!m_done) { R value; - if(!m_source.GetValue(name, value)) + if (!m_source.GetValue(name, value)) throw InvalidArgument(std::string(typeid(T).name()) + ": Missing required parameter '" + name + "'"); (m_pObject->*pm)(value); } diff --git a/cryptlib.h b/cryptlib.h index 2729008c..d0a3ee0f 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -299,7 +299,7 @@ public: CRYPTOPP_DLL bool GetAsUIntValue(const char *name, unsigned int &value) const { int v; - if(!GetValue(name, v) || v < 0) return false; + if (!GetValue(name, v) || v < 0) return false; value = static_cast(v); return true; } @@ -314,7 +314,7 @@ public: CRYPTOPP_DLL unsigned int GetAsUIntValueWithDefault(const char *name, unsigned int defaultValue) const { int v; - if(!GetValue(name, v) || v < 0) return defaultValue; + if (!GetValue(name, v) || v < 0) return defaultValue; return static_cast(v); } diff --git a/gzip.cpp b/gzip.cpp index 09e420a7..1e16e1c6 100644 --- a/gzip.cpp +++ b/gzip.cpp @@ -65,12 +65,12 @@ void Gunzip::ProcessPrestreamHeader() if (flags & FILENAME) // skip filename do - if(!m_inQueue.Get(b)) throw HeaderErr(); + if (!m_inQueue.Get(b)) throw HeaderErr(); while (b); if (flags & COMMENTS) // skip comments do - if(!m_inQueue.Get(b)) throw HeaderErr(); + if (!m_inQueue.Get(b)) throw HeaderErr(); while (b); } diff --git a/hkdf.h b/hkdf.h index d781b628..c80edc10 100644 --- a/hkdf.h +++ b/hkdf.h @@ -55,7 +55,7 @@ unsigned int HKDF::DeriveKey(byte *derived, size_t derivedLen, const byte *se CRYPTOPP_ASSERT(derived && derivedLen); CRYPTOPP_ASSERT(derivedLen <= MaxDerivedKeyLength()); - if(derivedLen > MaxDerivedKeyLength()) + if (derivedLen > MaxDerivedKeyLength()) throw InvalidArgument("HKDF: derivedLen must be less than or equal to MaxDerivedKeyLength"); HMAC hmac; @@ -74,8 +74,8 @@ unsigned int HKDF::DeriveKey(byte *derived, size_t derivedLen, const byte *se while (derivedLen > 0) { - if(block++) {hmac.Update(buffer, buffer.size());} - if(context && contextLen) {hmac.Update(context, contextLen);} + if (block++) {hmac.Update(buffer, buffer.size());} + if (context && contextLen) {hmac.Update(context, contextLen);} hmac.CalculateDigest(buffer, &block, 1); size_t segmentLen = STDMIN(derivedLen, DIGEST_SIZE); diff --git a/ida.cpp b/ida.cpp index 06df841b..6dda196b 100644 --- a/ida.cpp +++ b/ida.cpp @@ -380,7 +380,7 @@ size_t PaddingRemover::Put2(const byte *begin, size_t length, int messageEnd, bo if (m_possiblePadding) { - size_t len = find_if(begin, end, bind2nd(not_equal_to(), byte(0))) - begin; + size_t len = find_if (begin, end, bind2nd(not_equal_to(), byte(0))) - begin; m_zeroCount += len; begin += len; if (begin == end) @@ -401,7 +401,7 @@ size_t PaddingRemover::Put2(const byte *begin, size_t length, int messageEnd, bo #else typedef reverse_iterator RevIt; #endif - const byte *x = find_if(RevIt(end), RevIt(begin), bind2nd(not_equal_to(), byte(0))).base(); + const byte *x = find_if (RevIt(end), RevIt(begin), bind2nd(not_equal_to(), byte(0))).base(); if (x != begin && *(x-1) == 1) { AttachedTransformation()->Put(begin, x-begin-1); diff --git a/iterhash.cpp b/iterhash.cpp index f837165d..b8bf8669 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -28,7 +28,7 @@ template void IteratedHashBase::Update(const byte { if (num+len >= blockSize) { - if(data && input) + if (data && input) memcpy(data+num, input, blockSize-num); HashBlock(dataBuf); @@ -39,7 +39,7 @@ template void IteratedHashBase::Update(const byte } else { - if(data && input) + if (data && input) memcpy(data+num, input, len); return; @@ -64,7 +64,7 @@ template void IteratedHashBase::Update(const byte else do { // copy input first if it's not aligned correctly - if(data && input) + if (data && input) memcpy(data, input, blockSize); HashBlock(dataBuf); diff --git a/misc.h b/misc.h index 06cc3c62..7a93ef98 100644 --- a/misc.h +++ b/misc.h @@ -205,7 +205,7 @@ inline void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t cou // TODO: fix callers. Its easier than it sounds because of the way // Put and Put2 are used in filters. - if(dest && src && count) + if (dest && src && count) memcpy(dest, src, count); } @@ -219,7 +219,7 @@ inline void memmove_s(void *dest, size_t sizeInBytes, const void *src, size_t co // TODO: fix callers. Its easier than it sounds because of the way // Put and Put2 are used in filters. - if(dest && src && count) + if (dest && src && count) memmove(dest, src, count); } @@ -237,8 +237,8 @@ inline void * memset_z(void *ptr, int value, size_t num) if (__builtin_constant_p(num) && num==0) return ptr; #endif - if(!ptr) return NULL; - if(!num) return ptr; + if (!ptr) return NULL; + if (!num) return ptr; return memset(ptr, value, num); } @@ -1531,7 +1531,7 @@ inline void PutWord(bool assumeAligned, ByteOrder order, byte *block, T value, c T t1, t2 = 0; t1 = ConditionalByteReverse(order, value); - if(xorBlock) memmove(&t2, xorBlock, sizeof(T)); + if (xorBlock) memmove(&t2, xorBlock, sizeof(T)); memmove(block, &(t1 ^= t2), sizeof(T)); } diff --git a/modes.cpp b/modes.cpp index fc26015c..dee0f30f 100644 --- a/modes.cpp +++ b/modes.cpp @@ -52,7 +52,7 @@ void CFB_ModePolicy::TransformRegister() m_cipher->ProcessBlock(m_register, m_temp); const unsigned int updateSize = BlockSize()-m_feedbackSize; - if(updateSize) + if (updateSize) memmove_s(m_register, m_register.size(), m_register+m_feedbackSize, updateSize); memcpy_s(m_register+updateSize, m_register.size()-updateSize, m_temp, m_feedbackSize); } diff --git a/oaep.cpp b/oaep.cpp index 7af7051a..957c91ed 100644 --- a/oaep.cpp +++ b/oaep.cpp @@ -87,7 +87,7 @@ DecodingResult OAEP_Base::Unpad(const byte *oaepBlock, size_t oaepBlockLen, byte // DB = pHash' || 00 ... || 01 || M byte *M = std::find(maskedDB+hLen, maskedDB+dbLen, 0x01); invalid = (M == maskedDB+dbLen) || invalid; - invalid = (std::find_if(maskedDB+hLen, M, std::bind2nd(std::not_equal_to(), byte(0))) != M) || invalid; + invalid = (std::find_if (maskedDB+hLen, M, std::bind2nd(std::not_equal_to(), byte(0))) != M) || invalid; invalid = !pHash->VerifyDigest(maskedDB, encodingParameters.begin(), encodingParameters.size()) || invalid; if (invalid) diff --git a/osrng.cpp b/osrng.cpp index 76e486b4..1b2b77d7 100644 --- a/osrng.cpp +++ b/osrng.cpp @@ -47,7 +47,7 @@ OS_RNG_Err::OS_RNG_Err(const std::string &operation) MicrosoftCryptoProvider::MicrosoftCryptoProvider() { - if(!CryptAcquireContext(&m_hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) + if (!CryptAcquireContext(&m_hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) throw OS_RNG_Err("CryptAcquireContext"); } diff --git a/pssr.cpp b/pssr.cpp index 2dbe2b27..a097e972 100644 --- a/pssr.cpp +++ b/pssr.cpp @@ -78,7 +78,7 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng, xorbuf(xorStart + 1, recoverableMessage, recoverableMessageLength); xorbuf(xorStart + 1 + recoverableMessageLength, salt, salt.size()); - if(representative && hashIdentifier.first) + if (representative && hashIdentifier.first) memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second); representative[representativeByteLength - 1] = hashIdentifier.second ? 0xcc : 0xbc; @@ -115,13 +115,13 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative( // extract salt and recoverableMessage from DB = 00 ... || 01 || M || salt byte *salt = representative + representativeByteLength - u - digestSize - saltSize; - byte *M = std::find_if(representative, salt-1, std::bind2nd(std::not_equal_to(), byte(0))); + byte *M = std::find_if (representative, salt-1, std::bind2nd(std::not_equal_to(), byte(0))); recoverableMessageLength = salt-M-1; if (*M == 0x01 && (size_t)(M - representative - (representativeBitLength % 8 != 0)) >= MinPadLen(digestSize) && recoverableMessageLength <= MaxRecoverableLength(representativeBitLength, hashIdentifier.second, digestSize)) { - if(recoverableMessage && M && recoverableMessageLength) + if (recoverableMessage && M && recoverableMessageLength) memcpy(recoverableMessage, M+1, recoverableMessageLength); } else diff --git a/queue.cpp b/queue.cpp index 19943215..3beb731c 100644 --- a/queue.cpp +++ b/queue.cpp @@ -42,7 +42,7 @@ public: inline size_t Put(const byte *begin, size_t length) { - if(!begin || !length) return length; + if (!begin || !length) return length; size_t l = STDMIN(length, MaxSize()-m_tail); if (buf+m_tail != begin) memcpy(buf+m_tail, begin, l); @@ -61,7 +61,7 @@ public: inline size_t Peek(byte *target, size_t copyMax) const { - if(!target || !copyMax) return 0; + if (!target || !copyMax) return 0; size_t len = STDMIN(copyMax, m_tail-m_head); memcpy(target, buf+m_head, len); return len; @@ -428,7 +428,7 @@ byte * ByteQueue::CreatePutSpace(size_t &size) ByteQueue & ByteQueue::operator=(const ByteQueue &rhs) { - if(this == &rhs) return *this; + if (this == &rhs) return *this; Destroy(); CopyFrom(rhs); diff --git a/rw.cpp b/rw.cpp index 5d066f4c..0ddb0abd 100644 --- a/rw.cpp +++ b/rw.cpp @@ -124,7 +124,7 @@ void InvertibleRWFunction::PrecomputeTweakedRoots() const { ModularArithmetic modp(m_p), modq(m_q); - #pragma omp parallel sections if(CRYPTOPP_RW_USE_OMP) + #pragma omp parallel sections if (CRYPTOPP_RW_USE_OMP) { #pragma omp section m_pre_2_9p = modp.Exponentiate(2, (9 * m_p - 11)/8); @@ -150,7 +150,7 @@ void InvertibleRWFunction::LoadPrecomputation(BufferedTransformation &bt) void InvertibleRWFunction::SavePrecomputation(BufferedTransformation &bt) const { - if(!m_precompute) + if (!m_precompute) Precompute(); DERSequenceEncoder seq(bt); @@ -187,7 +187,7 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const { DoQuickSanityCheck(); - if(!m_precompute) + if (!m_precompute) Precompute(); ModularArithmetic modn(m_n), modp(m_p), modq(m_q); @@ -210,19 +210,19 @@ Integer InvertibleRWFunction::CalculateInverse(RandomNumberGenerator &rng, const Integer e, f; const Integer U = modq.Exponentiate(h, (q+1)/8); - if(((modq.Exponentiate(U, 4) - h) % q).IsZero()) + if (((modq.Exponentiate(U, 4) - h) % q).IsZero()) e = Integer::One(); else e = -1; const Integer eh = e*h, V = modp.Exponentiate(eh, (p-3)/8); - if(((modp.Multiply(modp.Exponentiate(V, 4), modp.Exponentiate(eh, 2)) - eh) % p).IsZero()) + if (((modp.Multiply(modp.Exponentiate(V, 4), modp.Exponentiate(eh, 2)) - eh) % p).IsZero()) f = Integer::One(); else f = 2; Integer W, X; - #pragma omp parallel sections if(CRYPTOPP_RW_USE_OMP) + #pragma omp parallel sections if (CRYPTOPP_RW_USE_OMP) { #pragma omp section { diff --git a/smartptr.h b/smartptr.h index 20efd815..e05a15f1 100644 --- a/smartptr.h +++ b/smartptr.h @@ -114,7 +114,7 @@ public: template value_ptr& value_ptr::operator=(const value_ptr& rhs) { - if(this != &rhs) + if (this != &rhs) { T *old_p = this->m_p; this->m_p = rhs.m_p ? new T(*rhs.m_p) : NULL; @@ -138,7 +138,7 @@ public: template clonable_ptr& clonable_ptr::operator=(const clonable_ptr& rhs) { - if(this != &rhs) + if (this != &rhs) { T *old_p = this->m_p; this->m_p = rhs.m_p ? rhs.m_p->Clone() : NULL; @@ -225,7 +225,7 @@ template T* counted_ptr::get() template counted_ptr & counted_ptr::operator=(const counted_ptr& rhs) { - if(this == &rhs) { return *this; } + if (this == &rhs) { return *this; } if (m_p != rhs.m_p) { diff --git a/trap.h b/trap.h index 747e6901..436c024a 100644 --- a/trap.h +++ b/trap.h @@ -23,7 +23,7 @@ // Linux and Unix #if !defined(NDEBUG) && defined(CRYPTOPP_UNIX_AVAILABLE) # define CRYPTOPP_ASSERT(exp) { \ - if(!(exp)) { \ + if (!(exp)) { \ std::ostringstream oss; \ oss << "Assertion failed: " << (char*)(__FILE__) << "(" \ << (int)(__LINE__) << "): " << (char*)(__func__) \ diff --git a/validat0.cpp b/validat0.cpp index 64144e7d..a8461fcc 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -337,14 +337,14 @@ bool TestConversion() signed int v; bool p = true; { // Guard i686 collision of type sizes - if(sizeof(signed int) != sizeof(signed long)) + if (sizeof(signed int) != sizeof(signed long)) { signed long v1 = std::numeric_limits::min(); p = !SafeConvert(v1, v) && p; signed long v2 = std::numeric_limits::max(); p = !SafeConvert(v2, v) && p; unsigned long v3 = std::numeric_limits::max(); p = !SafeConvert(v3, v) && p; } // Guard i686 collision of type sizes - if(sizeof(signed int) != sizeof(signed long long)) + if (sizeof(signed int) != sizeof(signed long long)) { signed long long v1 = std::numeric_limits::min(); p = !SafeConvert(v1, v) && p; signed long long v2 = std::numeric_limits::max(); p = !SafeConvert(v2, v) && p; @@ -373,12 +373,12 @@ bool TestConversion() unsigned int v; bool p = true; { // Guard i686 collision of type sizes - if(sizeof(unsigned int) != sizeof(unsigned long)) + if (sizeof(unsigned int) != sizeof(unsigned long)) { unsigned long v1 = std::numeric_limits::max(); p = !SafeConvert(v1, v) && p; } // Guard i686 collision of type sizes - if(sizeof(unsigned int) != sizeof(unsigned long long)) + if (sizeof(unsigned int) != sizeof(unsigned long long)) { unsigned long long v1 = std::numeric_limits::max(); p = !SafeConvert(v1, v) && p; } @@ -406,7 +406,7 @@ bool TestConversion() /********** signed long overflow **********/ { // Guard x86_64 collision of type sizes - if(sizeof(signed long) != sizeof(signed long long)) + if (sizeof(signed long) != sizeof(signed long long)) { signed long v; bool p = true; { @@ -439,7 +439,7 @@ bool TestConversion() /********** unsigned long overflow **********/ { // Guard x86_64 collision of type sizes - if(sizeof(unsigned long) != sizeof(unsigned long long)) + if (sizeof(unsigned long) != sizeof(unsigned long long)) { unsigned long v; bool p = true; { diff --git a/zdeflate.cpp b/zdeflate.cpp index b12de1a0..9b0aea03 100644 --- a/zdeflate.cpp +++ b/zdeflate.cpp @@ -668,11 +668,11 @@ void Deflator::EncodeBlock(bool eof, unsigned int blockType) m_literalCounts[256] = 1; HuffmanEncoder::GenerateCodeLengths(literalCodeLengths, 15, m_literalCounts, 286); m_dynamicLiteralEncoder.Initialize(literalCodeLengths, 286); - unsigned int hlit = (unsigned int)(find_if(RevIt(literalCodeLengths.end()), RevIt(literalCodeLengths.begin()+257), bind2nd(not_equal_to(), 0)).base() - (literalCodeLengths.begin()+257)); + unsigned int hlit = (unsigned int)(find_if (RevIt(literalCodeLengths.end()), RevIt(literalCodeLengths.begin()+257), bind2nd(not_equal_to(), 0)).base() - (literalCodeLengths.begin()+257)); HuffmanEncoder::GenerateCodeLengths(distanceCodeLengths, 15, m_distanceCounts, 30); m_dynamicDistanceEncoder.Initialize(distanceCodeLengths, 30); - unsigned int hdist = (unsigned int)(find_if(RevIt(distanceCodeLengths.end()), RevIt(distanceCodeLengths.begin()+1), bind2nd(not_equal_to(), 0)).base() - (distanceCodeLengths.begin()+1)); + unsigned int hdist = (unsigned int)(find_if (RevIt(distanceCodeLengths.end()), RevIt(distanceCodeLengths.begin()+1), bind2nd(not_equal_to(), 0)).base() - (distanceCodeLengths.begin()+1)); SecBlockWithHint combinedLengths(hlit+257+hdist+1); memcpy(combinedLengths, literalCodeLengths, (hlit+257)*sizeof(unsigned int));