From 6ab1a729efba62d2ba83c7db967881a9a8ec316c Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 1 Aug 2017 20:42:55 -0400 Subject: Cleared unused variable warnings --- mdc.h | 1 + randpool.cpp | 111 ++++++++++++++++++++++++++++++----------------------------- randpool.h | 4 ++- 3 files changed, 60 insertions(+), 56 deletions(-) diff --git a/mdc.h b/mdc.h index f246b5bb..c3e8d2ce 100644 --- a/mdc.h +++ b/mdc.h @@ -37,6 +37,7 @@ class MDC : public MDC_Info public: void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms) { + CRYPTOPP_UNUSED(params); this->AssertValidKeyLength(length); memcpy_s(m_key, m_key.size(), userKey, this->KEYLENGTH); m_hash.CorrectEndianess(Key(), Key(), this->KEYLENGTH); diff --git a/randpool.cpp b/randpool.cpp index a904c6eb..39afd72f 100644 --- a/randpool.cpp +++ b/randpool.cpp @@ -25,8 +25,8 @@ NAMESPACE_BEGIN(CryptoPP) RandomPool::RandomPool() : m_pCipher(new AES::Encryption), m_keySet(false) { - memset(m_key, 0, m_key.SizeInBytes()); - memset(m_seed, 0, m_seed.SizeInBytes()); + ::memset(m_key, 0, m_key.SizeInBytes()); + ::memset(m_seed, 0, m_seed.SizeInBytes()); } void RandomPool::IncorporateEntropy(const byte *input, size_t length) @@ -57,8 +57,8 @@ void RandomPool::GenerateIntoBufferedTransformation(BufferedTransformation &targ // UBsan finding: signed integer overflow: 1876017710 + 1446085457 cannot be represented in type 'long int' // *(time_t *)(m_seed.data()+8) += t; word64 tt1 = 0, tt2 = (word64)t; - memcpy(&tt1, m_seed.data()+8, 8); - memcpy(m_seed.data()+8, &(tt2 += tt1), 8); + ::memcpy(&tt1, m_seed.data()+8, 8); + ::memcpy(m_seed.data()+8, &(tt2 += tt1), 8); // Wipe the intermediates *((volatile TimerWord*)&tw) = 0; @@ -81,80 +81,81 @@ typedef MDC OldRandomPoolCipher; OldRandomPool::OldRandomPool(unsigned int poolSize) : pool(poolSize), key(OldRandomPoolCipher::DEFAULT_KEYLENGTH), addPos(0), getPos(poolSize) { - CRYPTOPP_ASSERT(poolSize > key.size()); - memset(pool, 0, poolSize); - memset(key, 0, key.size()); + CRYPTOPP_ASSERT(poolSize > key.size()); + ::memset(pool, 0, poolSize); + ::memset(key, 0, key.size()); } void OldRandomPool::Stir() { - CFB_Mode::Encryption cipher; + CFB_Mode::Encryption cipher; - for (int i=0; i<2; i++) - { - cipher.SetKeyWithIV(key, key.size(), pool.end()-cipher.IVSize()); - cipher.ProcessString(pool, pool.size()); - memcpy(key, pool, key.size()); - } + for (int i=0; i<2; i++) + { + cipher.SetKeyWithIV(key, key.size(), pool.end()-cipher.IVSize()); + cipher.ProcessString(pool, pool.size()); + ::memcpy(key, pool, key.size()); + } - addPos = 0; - getPos = key.size(); + addPos = 0; + getPos = key.size(); } size_t OldRandomPool::Put2(const byte *inString, size_t length, int messageEnd, bool blocking) { - size_t t; - - while (length > (t = pool.size() - addPos)) - { - xorbuf(pool+addPos, inString, t); - inString += t; - length -= t; - Stir(); - } - - if (length) - { - xorbuf(pool+addPos, inString, length); - addPos += length; - getPos = pool.size(); // Force stir on get - } - - return 0; + CRYPTOPP_UNUSED(messageEnd); CRYPTOPP_UNUSED(blocking); + + size_t t; + while (length > (t = pool.size() - addPos)) + { + xorbuf(pool+addPos, inString, t); + inString += t; + length -= t; + Stir(); + } + + if (length) + { + xorbuf(pool+addPos, inString, length); + addPos += length; + getPos = pool.size(); // Force stir on get + } + + return 0; } size_t OldRandomPool::TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel, bool blocking) { - if (!blocking) - throw NotImplemented("OldRandomPool: nonblocking transfer is not implemented by this object"); - - lword size = transferBytes; - - while (size > 0) - { - if (getPos == pool.size()) - Stir(); - size_t t = UnsignedMin(pool.size() - getPos, size); - target.ChannelPut(channel, pool+getPos, t); - size -= t; - getPos += t; - } - - return 0; + if (!blocking) + throw NotImplemented("OldRandomPool: nonblocking transfer is not implemented by this object"); + + lword size = transferBytes; + + while (size > 0) + { + if (getPos == pool.size()) + Stir(); + size_t t = UnsignedMin(pool.size() - getPos, size); + target.ChannelPut(channel, pool+getPos, t); + size -= t; + getPos += t; + } + + return 0; } byte OldRandomPool::GenerateByte() { - if (getPos == pool.size()) - Stir(); + if (getPos == pool.size()) + Stir(); - return pool[getPos++]; + return pool[getPos++]; } void OldRandomPool::GenerateBlock(byte *outString, size_t size) { - ArraySink sink(outString, size); - TransferTo(sink, size); + ArraySink sink(outString, size); + TransferTo(sink, size); } NAMESPACE_END diff --git a/randpool.h b/randpool.h index ffcf4057..37dda408 100644 --- a/randpool.h +++ b/randpool.h @@ -87,13 +87,15 @@ public: size_t TransferTo2(BufferedTransformation &target, lword &transferBytes, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true); size_t CopyRangeTo2(BufferedTransformation &target, lword &begin, lword end=LWORD_MAX, const std::string &channel=DEFAULT_CHANNEL, bool blocking=true) const { + CRYPTOPP_UNUSED(target); CRYPTOPP_UNUSED(begin); CRYPTOPP_UNUSED(end); + CRYPTOPP_UNUSED(channel); CRYPTOPP_UNUSED(blocking); throw NotImplemented("OldRandomPool: CopyRangeTo2() is not supported by this store"); } byte GenerateByte(); void GenerateBlock(byte *output, size_t size); - void IsolatedInitialize(const NameValuePairs ¶meters) {} + void IsolatedInitialize(const NameValuePairs ¶meters) {CRYPTOPP_UNUSED(parameters);} protected: void Stir(); -- cgit v1.2.1