Clear clang-tidy warnings
parent
85993b2529
commit
30bcc7022d
40
integer.cpp
40
integer.cpp
|
|
@ -3645,32 +3645,24 @@ std::istream& operator>>(std::istream& in, Integer &a)
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure base 10 is default
|
||||||
|
inline int FlagToBase(long f) {
|
||||||
|
return f == std::ios::hex ? 16 : (f == std::ios::oct ? 8 : 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline char FlagToSuffix(long f) {
|
||||||
|
return f == std::ios::hex ? 'h' : (f == std::ios::oct ? 'o' : '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure base 10 is default
|
||||||
std::ostream& operator<<(std::ostream& out, const Integer &a)
|
std::ostream& operator<<(std::ostream& out, const Integer &a)
|
||||||
{
|
{
|
||||||
// Get relevant conversion specifications from ostream.
|
// Get relevant conversion specifications from ostream.
|
||||||
const long f = out.flags() & std::ios::basefield; // Get base digits.
|
const long f = out.flags() & std::ios::basefield;
|
||||||
int base, block;
|
const int base = FlagToBase(f);
|
||||||
char suffix;
|
const char suffix = FlagToSuffix(f);
|
||||||
switch(f)
|
|
||||||
{
|
|
||||||
case std::ios::oct :
|
|
||||||
base = 8;
|
|
||||||
block = 8;
|
|
||||||
suffix = 'o';
|
|
||||||
break;
|
|
||||||
case std::ios::hex :
|
|
||||||
base = 16;
|
|
||||||
block = 4;
|
|
||||||
suffix = 'h';
|
|
||||||
break;
|
|
||||||
default :
|
|
||||||
base = 10;
|
|
||||||
block = 3;
|
|
||||||
suffix = '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer temp1=a, temp2;
|
Integer temp1=a, temp2;
|
||||||
|
|
||||||
if (a.IsNegative())
|
if (a.IsNegative())
|
||||||
{
|
{
|
||||||
out << '-';
|
out << '-';
|
||||||
|
|
@ -3698,8 +3690,6 @@ std::ostream& operator<<(std::ostream& out, const Integer &a)
|
||||||
while (i--)
|
while (i--)
|
||||||
{
|
{
|
||||||
out << s[i];
|
out << s[i];
|
||||||
// if (i && !(i%block))
|
|
||||||
// out << ",";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CRYPTOPP_USE_STD_SHOWBASE
|
#ifdef CRYPTOPP_USE_STD_SHOWBASE
|
||||||
|
|
@ -3873,7 +3863,7 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
|
||||||
word borrow = Subtract(diff.reg, a.reg, b.reg, bSize);
|
word borrow = Subtract(diff.reg, a.reg, b.reg, bSize);
|
||||||
CopyWords(diff.reg+bSize, a.reg+bSize, aSize-bSize);
|
CopyWords(diff.reg+bSize, a.reg+bSize, aSize-bSize);
|
||||||
borrow = Decrement(diff.reg+bSize, aSize-bSize, borrow);
|
borrow = Decrement(diff.reg+bSize, aSize-bSize, borrow);
|
||||||
CRYPTOPP_ASSERT(!borrow);
|
CRYPTOPP_ASSERT(!borrow); CRYPTOPP_UNUSED(borrow);
|
||||||
diff.sign = Integer::POSITIVE;
|
diff.sign = Integer::POSITIVE;
|
||||||
}
|
}
|
||||||
else if (aSize == bSize)
|
else if (aSize == bSize)
|
||||||
|
|
@ -3894,7 +3884,7 @@ void PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)
|
||||||
word borrow = Subtract(diff.reg, b.reg, a.reg, aSize);
|
word borrow = Subtract(diff.reg, b.reg, a.reg, aSize);
|
||||||
CopyWords(diff.reg+aSize, b.reg+aSize, bSize-aSize);
|
CopyWords(diff.reg+aSize, b.reg+aSize, bSize-aSize);
|
||||||
borrow = Decrement(diff.reg+aSize, bSize-aSize, borrow);
|
borrow = Decrement(diff.reg+aSize, bSize-aSize, borrow);
|
||||||
CRYPTOPP_ASSERT(!borrow);
|
CRYPTOPP_ASSERT(!borrow); CRYPTOPP_UNUSED(borrow);
|
||||||
diff.sign = Integer::NEGATIVE;
|
diff.sign = Integer::NEGATIVE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
tea.cpp
15
tea.cpp
|
|
@ -9,6 +9,9 @@ NAMESPACE_BEGIN(CryptoPP)
|
||||||
static const word32 DELTA = 0x9e3779b9;
|
static const word32 DELTA = 0x9e3779b9;
|
||||||
typedef BlockGetAndPut<word32, BigEndian> Block;
|
typedef BlockGetAndPut<word32, BigEndian> Block;
|
||||||
|
|
||||||
|
#define UINT32_CAST(x) ((word32*)(void*)(x))
|
||||||
|
#define CONST_UINT32_CAST(x) ((const word32*)(const void*)(x))
|
||||||
|
|
||||||
void TEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms)
|
void TEA::Base::UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms)
|
||||||
{
|
{
|
||||||
AssertValidKeyLength(length);
|
AssertValidKeyLength(length);
|
||||||
|
|
@ -98,10 +101,10 @@ void BTEA::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by
|
||||||
CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf<word32>()));
|
CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf<word32>()));
|
||||||
|
|
||||||
unsigned int n = m_blockSize / 4;
|
unsigned int n = m_blockSize / 4;
|
||||||
word32 *v = (word32*)(void *)outBlock;
|
word32 *v = UINT32_CAST(outBlock);
|
||||||
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, (const word32*)(void *)inBlock, m_blockSize);
|
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, CONST_UINT32_CAST(inBlock), m_blockSize);
|
||||||
|
|
||||||
word32 y = v[0], z = v[n-1], e;
|
word32 y, z = v[n-1], e;
|
||||||
word32 p, q = 6+52/n;
|
word32 p, q = 6+52/n;
|
||||||
word32 sum = 0;
|
word32 sum = 0;
|
||||||
|
|
||||||
|
|
@ -128,10 +131,10 @@ void BTEA::Dec::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, by
|
||||||
CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf<word32>()));
|
CRYPTOPP_ASSERT(IsAlignedOn(outBlock,GetAlignmentOf<word32>()));
|
||||||
|
|
||||||
unsigned int n = m_blockSize / 4;
|
unsigned int n = m_blockSize / 4;
|
||||||
word32 *v = (word32*)(void *)outBlock;
|
word32 *v = UINT32_CAST(outBlock);
|
||||||
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, (const word32*)(void *)inBlock, m_blockSize);
|
ConditionalByteReverse(BIG_ENDIAN_ORDER, v, CONST_UINT32_CAST(inBlock), m_blockSize);
|
||||||
|
|
||||||
word32 y = v[0], z = v[n-1], e;
|
word32 y = v[0], z, e;
|
||||||
word32 p, q = 6+52/n;
|
word32 p, q = 6+52/n;
|
||||||
word32 sum = q * DELTA;
|
word32 sum = q * DELTA;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue