mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-26 19:30:21 +00:00
Clear clang-tidy warnings
This commit is contained in:
parent
e546b2af85
commit
51db9eb436
12
arc4.cpp
12
arc4.cpp
@ -25,9 +25,9 @@ ARC4_Base::~ARC4_Base()
|
|||||||
m_x = m_y = 0;
|
m_x = m_y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const NameValuePairs ¶ms)
|
void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
|
||||||
{
|
{
|
||||||
AssertValidKeyLength(keyLen);
|
AssertValidKeyLength(length);
|
||||||
|
|
||||||
m_x = 1;
|
m_x = 1;
|
||||||
m_y = 0;
|
m_y = 0;
|
||||||
@ -44,7 +44,7 @@ void ARC4_Base::UncheckedSetKey(const byte *key, unsigned int keyLen, const Name
|
|||||||
stateIndex &= 0xff;
|
stateIndex &= 0xff;
|
||||||
m_state[i] = m_state[stateIndex];
|
m_state[i] = m_state[stateIndex];
|
||||||
m_state[stateIndex] = byte(a);
|
m_state[stateIndex] = byte(a);
|
||||||
if (++keyIndex >= keyLen)
|
if (++keyIndex >= length)
|
||||||
keyIndex = 0;
|
keyIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +99,9 @@ void ARC4_Base::ProcessData(byte *outString, const byte *inString, size_t length
|
|||||||
m_y = byte(y);
|
m_y = byte(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARC4_Base::DiscardBytes(size_t length)
|
void ARC4_Base::DiscardBytes(size_t n)
|
||||||
{
|
{
|
||||||
if (length == 0)
|
if (n == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
byte *const s = m_state;
|
byte *const s = m_state;
|
||||||
@ -112,7 +112,7 @@ void ARC4_Base::DiscardBytes(size_t length)
|
|||||||
{
|
{
|
||||||
MakeByte(x, y, s);
|
MakeByte(x, y, s);
|
||||||
}
|
}
|
||||||
while(--length);
|
while(--n);
|
||||||
|
|
||||||
m_x = byte(x);
|
m_x = byte(x);
|
||||||
m_y = byte(y);
|
m_y = byte(y);
|
||||||
|
@ -22,7 +22,7 @@ unsigned int PublicBlumBlumShub::GenerateBit()
|
|||||||
bitsLeft = maxBits;
|
bitsLeft = maxBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
return current.GetBit(--bitsLeft);
|
return static_cast<unsigned int>(current.GetBit(--bitsLeft));
|
||||||
}
|
}
|
||||||
|
|
||||||
byte PublicBlumBlumShub::GenerateByte()
|
byte PublicBlumBlumShub::GenerateByte()
|
||||||
|
45
cpu.cpp
45
cpu.cpp
@ -58,8 +58,9 @@ extern "C" {
|
|||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
static jmp_buf s_jmpNoCPUID;
|
static jmp_buf s_jmpNoCPUID;
|
||||||
static void SigIllHandlerCPUID(int)
|
static void SigIllHandlerCPUID(int unused)
|
||||||
{
|
{
|
||||||
|
CRYPTOPP_UNUSED(unused);
|
||||||
longjmp(s_jmpNoCPUID, 1);
|
longjmp(s_jmpNoCPUID, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +128,7 @@ bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
|||||||
// not return non-0, then it is mostly useless. The code below converts basic
|
// not return non-0, then it is mostly useless. The code below converts basic
|
||||||
// function value to a true/false return value.
|
// function value to a true/false return value.
|
||||||
if(func == 0)
|
if(func == 0)
|
||||||
return !!output[0];
|
return output[0] != 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@ -141,7 +142,7 @@ bool CpuId(word32 func, word32 subfunc, word32 output[4])
|
|||||||
|
|
||||||
# ifndef __MINGW32__
|
# ifndef __MINGW32__
|
||||||
volatile sigset_t oldMask;
|
volatile sigset_t oldMask;
|
||||||
if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask))
|
if (sigprocmask(0, NULLPTR, (sigset_t*)&oldMask) != 0)
|
||||||
return false;
|
return false;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -221,13 +222,13 @@ void DetectX86Features()
|
|||||||
// cpuid1[2] & (1 << 27) is XSAVE/XRESTORE and signals OS support for SSE; use it to avoid probes.
|
// cpuid1[2] & (1 << 27) is XSAVE/XRESTORE and signals OS support for SSE; use it to avoid probes.
|
||||||
// See http://github.com/weidai11/cryptopp/issues/511 and http://stackoverflow.com/a/22521619/608639
|
// See http://github.com/weidai11/cryptopp/issues/511 and http://stackoverflow.com/a/22521619/608639
|
||||||
if ((cpuid1[3] & (1 << 26)) != 0)
|
if ((cpuid1[3] & (1 << 26)) != 0)
|
||||||
g_hasSSE2 = (cpuid1[2] & (1 << 27)) || CPU_ProbeSSE2();
|
g_hasSSE2 = ((cpuid1[2] & (1 << 27)) != 0) || CPU_ProbeSSE2();
|
||||||
|
|
||||||
g_hasSSSE3 = g_hasSSE2 && (cpuid1[2] & (1<<9));
|
g_hasSSSE3 = g_hasSSE2 && ((cpuid1[2] & (1<< 9)) != 0);
|
||||||
g_hasSSE41 = g_hasSSE2 && (cpuid1[2] & (1<<19));
|
g_hasSSE41 = g_hasSSE2 && ((cpuid1[2] & (1<<19)) != 0);
|
||||||
g_hasSSE42 = g_hasSSE2 && (cpuid1[2] & (1<<20));
|
g_hasSSE42 = g_hasSSE2 && ((cpuid1[2] & (1<<20)) != 0);
|
||||||
g_hasAESNI = g_hasSSE2 && (cpuid1[2] & (1<<25));
|
g_hasAESNI = g_hasSSE2 && ((cpuid1[2] & (1<<25)) != 0);
|
||||||
g_hasCLMUL = g_hasSSE2 && (cpuid1[2] & (1<<1));
|
g_hasCLMUL = g_hasSSE2 && ((cpuid1[2] & (1<< 1)) != 0);
|
||||||
|
|
||||||
if (IsIntel(cpuid0))
|
if (IsIntel(cpuid0))
|
||||||
{
|
{
|
||||||
@ -238,15 +239,15 @@ void DetectX86Features()
|
|||||||
|
|
||||||
g_isP4 = ((cpuid1[0] >> 8) & 0xf) == 0xf;
|
g_isP4 = ((cpuid1[0] >> 8) & 0xf) == 0xf;
|
||||||
g_cacheLineSize = 8 * GETBYTE(cpuid1[1], 1);
|
g_cacheLineSize = 8 * GETBYTE(cpuid1[1], 1);
|
||||||
g_hasRDRAND = !!(cpuid1[2] /*ECX*/ & RDRAND_FLAG);
|
g_hasRDRAND = (cpuid1[2] /*ECX*/ & RDRAND_FLAG) != 0;
|
||||||
|
|
||||||
if (cpuid0[0] /*EAX*/ >= 7)
|
if (cpuid0[0] /*EAX*/ >= 7)
|
||||||
{
|
{
|
||||||
if (CpuId(7, 0, cpuid2))
|
if (CpuId(7, 0, cpuid2))
|
||||||
{
|
{
|
||||||
g_hasRDSEED = !!(cpuid2[1] /*EBX*/ & RDSEED_FLAG);
|
g_hasRDSEED = (cpuid2[1] /*EBX*/ & RDSEED_FLAG) != 0;
|
||||||
g_hasADX = !!(cpuid2[1] /*EBX*/ & ADX_FLAG);
|
g_hasADX = (cpuid2[1] /*EBX*/ & ADX_FLAG) != 0;
|
||||||
g_hasSHA = !!(cpuid2[1] /*EBX*/ & SHA_FLAG);
|
g_hasSHA = (cpuid2[1] /*EBX*/ & SHA_FLAG) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -259,15 +260,15 @@ void DetectX86Features()
|
|||||||
|
|
||||||
CpuId(0x80000005, 0, cpuid2);
|
CpuId(0x80000005, 0, cpuid2);
|
||||||
g_cacheLineSize = GETBYTE(cpuid2[2], 0);
|
g_cacheLineSize = GETBYTE(cpuid2[2], 0);
|
||||||
g_hasRDRAND = !!(cpuid1[2] /*ECX*/ & RDRAND_FLAG);
|
g_hasRDRAND = (cpuid1[2] /*ECX*/ & RDRAND_FLAG) != 0;
|
||||||
|
|
||||||
if (cpuid0[0] /*EAX*/ >= 7)
|
if (cpuid0[0] /*EAX*/ >= 7)
|
||||||
{
|
{
|
||||||
if (CpuId(7, 0, cpuid2))
|
if (CpuId(7, 0, cpuid2))
|
||||||
{
|
{
|
||||||
g_hasRDSEED = !!(cpuid2[1] /*EBX*/ & RDSEED_FLAG);
|
g_hasRDSEED = (cpuid2[1] /*EBX*/ & RDSEED_FLAG) != 0;
|
||||||
g_hasADX = !!(cpuid2[1] /*EBX*/ & ADX_FLAG);
|
g_hasADX = (cpuid2[1] /*EBX*/ & ADX_FLAG) != 0;
|
||||||
g_hasSHA = !!(cpuid2[1] /*EBX*/ & SHA_FLAG);
|
g_hasSHA = (cpuid2[1] /*EBX*/ & SHA_FLAG) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,11 +285,11 @@ void DetectX86Features()
|
|||||||
{
|
{
|
||||||
// Extended features available
|
// Extended features available
|
||||||
CpuId(0xC0000001, 0, cpuid2);
|
CpuId(0xC0000001, 0, cpuid2);
|
||||||
g_hasPadlockRNG = !!(cpuid2[3] /*EDX*/ & RNG_FLAGS);
|
g_hasPadlockRNG = (cpuid2[3] /*EDX*/ & RNG_FLAGS) != 0;
|
||||||
g_hasPadlockACE = !!(cpuid2[3] /*EDX*/ & ACE_FLAGS);
|
g_hasPadlockACE = (cpuid2[3] /*EDX*/ & ACE_FLAGS) != 0;
|
||||||
g_hasPadlockACE2 = !!(cpuid2[3] /*EDX*/ & ACE2_FLAGS);
|
g_hasPadlockACE2 = (cpuid2[3] /*EDX*/ & ACE2_FLAGS) != 0;
|
||||||
g_hasPadlockPHE = !!(cpuid2[3] /*EDX*/ & PHE_FLAGS);
|
g_hasPadlockPHE = (cpuid2[3] /*EDX*/ & PHE_FLAGS) != 0;
|
||||||
g_hasPadlockPMM = !!(cpuid2[3] /*EDX*/ & PMM_FLAGS);
|
g_hasPadlockPMM = (cpuid2[3] /*EDX*/ & PMM_FLAGS) != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
159
cryptlib.cpp
159
cryptlib.cpp
@ -95,22 +95,25 @@ void SimpleKeyingInterface::ThrowIfInvalidIV(const byte *iv)
|
|||||||
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object cannot use a null IV");
|
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": this object cannot use a null IV");
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SimpleKeyingInterface::ThrowIfInvalidIVLength(int size)
|
size_t SimpleKeyingInterface::ThrowIfInvalidIVLength(int length)
|
||||||
{
|
{
|
||||||
if (size < 0)
|
size_t size = 0;
|
||||||
return (size_t)IVSize();
|
if (length < 0)
|
||||||
else if ((size_t)size < MinIVLength())
|
size = static_cast<size_t>(IVSize());
|
||||||
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": IV length " + IntToString(size) + " is less than the minimum of " + IntToString(MinIVLength()));
|
else if ((size_t)length < MinIVLength())
|
||||||
else if ((size_t)size > MaxIVLength())
|
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": IV length " + IntToString(length) + " is less than the minimum of " + IntToString(MinIVLength()));
|
||||||
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": IV length " + IntToString(size) + " exceeds the maximum of " + IntToString(MaxIVLength()));
|
else if ((size_t)length > MaxIVLength())
|
||||||
|
throw InvalidArgument(GetAlgorithm().AlgorithmName() + ": IV length " + IntToString(length) + " exceeds the maximum of " + IntToString(MaxIVLength()));
|
||||||
else
|
else
|
||||||
return (size_t)size;
|
size = static_cast<size_t>(length);
|
||||||
|
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size)
|
const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs ¶ms, size_t &size)
|
||||||
{
|
{
|
||||||
ConstByteArrayParameter ivWithLength;
|
ConstByteArrayParameter ivWithLength;
|
||||||
const byte *iv;
|
const byte *iv = NULLPTR;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
try {found = params.GetValue(Name::IV(), ivWithLength);}
|
try {found = params.GetValue(Name::IV(), ivWithLength);}
|
||||||
@ -121,25 +124,24 @@ const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs
|
|||||||
iv = ivWithLength.begin();
|
iv = ivWithLength.begin();
|
||||||
ThrowIfInvalidIV(iv);
|
ThrowIfInvalidIV(iv);
|
||||||
size = ThrowIfInvalidIVLength(static_cast<int>(ivWithLength.size()));
|
size = ThrowIfInvalidIVLength(static_cast<int>(ivWithLength.size()));
|
||||||
return iv;
|
|
||||||
}
|
}
|
||||||
else if (params.GetValue(Name::IV(), iv))
|
else if (params.GetValue(Name::IV(), iv))
|
||||||
{
|
{
|
||||||
ThrowIfInvalidIV(iv);
|
ThrowIfInvalidIV(iv);
|
||||||
size = IVSize();
|
size = static_cast<size_t>(IVSize());
|
||||||
return iv;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ThrowIfResynchronizable();
|
ThrowIfResynchronizable();
|
||||||
size = 0;
|
size = 0;
|
||||||
return NULLPTR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return iv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimpleKeyingInterface::GetNextIV(RandomNumberGenerator &rng, byte *IV)
|
void SimpleKeyingInterface::GetNextIV(RandomNumberGenerator &rng, byte *iv)
|
||||||
{
|
{
|
||||||
rng.GenerateBlock(IV, IVSize());
|
rng.GenerateBlock(iv, IVSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
|
size_t BlockTransformation::AdvancedProcessBlocks(const byte *inBlocks, const byte *xorBlocks, byte *outBlocks, size_t length, word32 flags) const
|
||||||
@ -227,11 +229,11 @@ size_t StreamTransformation::ProcessLastBlock(byte *outString, size_t outLength,
|
|||||||
{
|
{
|
||||||
outLength = inLength; // squash unused warning
|
outLength = inLength; // squash unused warning
|
||||||
ProcessData(outString, inString, inLength);
|
ProcessData(outString, inString, inLength);
|
||||||
return outLength;
|
|
||||||
}
|
}
|
||||||
else if (inLength != 0)
|
else if (inLength != 0)
|
||||||
throw NotImplemented(AlgorithmName() + ": this object doesn't support a special last block");
|
throw NotImplemented(AlgorithmName() + ": this object doesn't support a special last block");
|
||||||
return 0;
|
|
||||||
|
return outLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AuthenticatedSymmetricCipher::SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
|
void AuthenticatedSymmetricCipher::SpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength)
|
||||||
@ -381,12 +383,12 @@ RandomNumberGenerator & NullRNG()
|
|||||||
return s_nullRNG;
|
return s_nullRNG;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HashTransformation::TruncatedVerify(const byte *digestIn, size_t digestLength)
|
bool HashTransformation::TruncatedVerify(const byte *digest, size_t digestLength)
|
||||||
{
|
{
|
||||||
ThrowIfInvalidTruncatedSize(digestLength);
|
ThrowIfInvalidTruncatedSize(digestLength);
|
||||||
SecByteBlock digest(digestLength);
|
SecByteBlock calculated(digestLength);
|
||||||
TruncatedFinal(digest, digestLength);
|
TruncatedFinal(calculated, digestLength);
|
||||||
return VerifyBufsEqual(digest, digestIn, digestLength);
|
return VerifyBufsEqual(calculated, digest, digestLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HashTransformation::ThrowIfInvalidTruncatedSize(size_t size) const
|
void HashTransformation::ThrowIfInvalidTruncatedSize(size_t size) const
|
||||||
@ -431,150 +433,183 @@ bool BufferedTransformation::MessageSeriesEnd(int propagation, bool blocking)
|
|||||||
|
|
||||||
byte * BufferedTransformation::ChannelCreatePutSpace(const std::string &channel, size_t &size)
|
byte * BufferedTransformation::ChannelCreatePutSpace(const std::string &channel, size_t &size)
|
||||||
{
|
{
|
||||||
|
byte* space = NULLPTR;
|
||||||
if (channel.empty())
|
if (channel.empty())
|
||||||
return CreatePutSpace(size);
|
space = CreatePutSpace(size);
|
||||||
else
|
else
|
||||||
throw NoChannelSupport(AlgorithmName());
|
throw NoChannelSupport(AlgorithmName());
|
||||||
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::ChannelPut2(const std::string &channel, const byte *begin, size_t length, int messageEnd, bool blocking)
|
size_t BufferedTransformation::ChannelPut2(const std::string &channel, const byte *inString, size_t length, int messageEnd, bool blocking)
|
||||||
{
|
{
|
||||||
|
size_t size = 0;
|
||||||
if (channel.empty())
|
if (channel.empty())
|
||||||
return Put2(begin, length, messageEnd, blocking);
|
size = Put2(inString, length, messageEnd, blocking);
|
||||||
else
|
else
|
||||||
throw NoChannelSupport(AlgorithmName());
|
throw NoChannelSupport(AlgorithmName());
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::ChannelPutModifiable2(const std::string &channel, byte *begin, size_t length, int messageEnd, bool blocking)
|
size_t BufferedTransformation::ChannelPutModifiable2(const std::string &channel, byte *inString, size_t length, int messageEnd, bool blocking)
|
||||||
{
|
{
|
||||||
|
size_t size = 0;
|
||||||
if (channel.empty())
|
if (channel.empty())
|
||||||
return PutModifiable2(begin, length, messageEnd, blocking);
|
size = PutModifiable2(inString, length, messageEnd, blocking);
|
||||||
else
|
else
|
||||||
return ChannelPut2(channel, begin, length, messageEnd, blocking);
|
size = ChannelPut2(channel, inString, length, messageEnd, blocking);
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferedTransformation::ChannelFlush(const std::string &channel, bool completeFlush, int propagation, bool blocking)
|
bool BufferedTransformation::ChannelFlush(const std::string &channel, bool hardFlush, int propagation, bool blocking)
|
||||||
{
|
{
|
||||||
|
bool result = 0;
|
||||||
if (channel.empty())
|
if (channel.empty())
|
||||||
return Flush(completeFlush, propagation, blocking);
|
result = Flush(hardFlush, propagation, blocking);
|
||||||
else
|
else
|
||||||
throw NoChannelSupport(AlgorithmName());
|
throw NoChannelSupport(AlgorithmName());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferedTransformation::ChannelMessageSeriesEnd(const std::string &channel, int propagation, bool blocking)
|
bool BufferedTransformation::ChannelMessageSeriesEnd(const std::string &channel, int propagation, bool blocking)
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
if (channel.empty())
|
if (channel.empty())
|
||||||
return MessageSeriesEnd(propagation, blocking);
|
result = MessageSeriesEnd(propagation, blocking);
|
||||||
else
|
else
|
||||||
throw NoChannelSupport(AlgorithmName());
|
throw NoChannelSupport(AlgorithmName());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
lword BufferedTransformation::MaxRetrievable() const
|
lword BufferedTransformation::MaxRetrievable() const
|
||||||
{
|
{
|
||||||
|
lword size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->MaxRetrievable();
|
size = AttachedTransformation()->MaxRetrievable();
|
||||||
else
|
else
|
||||||
return CopyTo(TheBitBucket());
|
size = CopyTo(TheBitBucket());
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferedTransformation::AnyRetrievable() const
|
bool BufferedTransformation::AnyRetrievable() const
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->AnyRetrievable();
|
result = AttachedTransformation()->AnyRetrievable();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte b;
|
byte b;
|
||||||
return Peek(b) != 0;
|
result = Peek(b) != 0;
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::Get(byte &outByte)
|
size_t BufferedTransformation::Get(byte &outByte)
|
||||||
{
|
{
|
||||||
|
size_t size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->Get(outByte);
|
size = AttachedTransformation()->Get(outByte);
|
||||||
else
|
else
|
||||||
return Get(&outByte, 1);
|
size = Get(&outByte, 1);
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::Get(byte *outString, size_t getMax)
|
size_t BufferedTransformation::Get(byte *outString, size_t getMax)
|
||||||
{
|
{
|
||||||
|
size_t size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->Get(outString, getMax);
|
size = AttachedTransformation()->Get(outString, getMax);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ArraySink arraySink(outString, getMax);
|
ArraySink arraySink(outString, getMax);
|
||||||
return (size_t)TransferTo(arraySink, getMax);
|
size = (size_t)TransferTo(arraySink, getMax);
|
||||||
}
|
}
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::Peek(byte &outByte) const
|
size_t BufferedTransformation::Peek(byte &outByte) const
|
||||||
{
|
{
|
||||||
|
size_t size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->Peek(outByte);
|
size = AttachedTransformation()->Peek(outByte);
|
||||||
else
|
else
|
||||||
return Peek(&outByte, 1);
|
size = Peek(&outByte, 1);
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::Peek(byte *outString, size_t peekMax) const
|
size_t BufferedTransformation::Peek(byte *outString, size_t peekMax) const
|
||||||
{
|
{
|
||||||
|
size_t size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->Peek(outString, peekMax);
|
size = AttachedTransformation()->Peek(outString, peekMax);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ArraySink arraySink(outString, peekMax);
|
ArraySink arraySink(outString, peekMax);
|
||||||
return (size_t)CopyTo(arraySink, peekMax);
|
size = (size_t)CopyTo(arraySink, peekMax);
|
||||||
}
|
}
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
lword BufferedTransformation::Skip(lword skipMax)
|
lword BufferedTransformation::Skip(lword skipMax)
|
||||||
{
|
{
|
||||||
|
lword size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->Skip(skipMax);
|
size = AttachedTransformation()->Skip(skipMax);
|
||||||
else
|
else
|
||||||
return TransferTo(TheBitBucket(), skipMax);
|
size = TransferTo(TheBitBucket(), skipMax);
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
lword BufferedTransformation::TotalBytesRetrievable() const
|
lword BufferedTransformation::TotalBytesRetrievable() const
|
||||||
{
|
{
|
||||||
|
lword size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->TotalBytesRetrievable();
|
size = AttachedTransformation()->TotalBytesRetrievable();
|
||||||
else
|
else
|
||||||
return MaxRetrievable();
|
size = MaxRetrievable();
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int BufferedTransformation::NumberOfMessages() const
|
unsigned int BufferedTransformation::NumberOfMessages() const
|
||||||
{
|
{
|
||||||
|
unsigned int size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->NumberOfMessages();
|
size = AttachedTransformation()->NumberOfMessages();
|
||||||
else
|
else
|
||||||
return CopyMessagesTo(TheBitBucket());
|
size = CopyMessagesTo(TheBitBucket());
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferedTransformation::AnyMessages() const
|
bool BufferedTransformation::AnyMessages() const
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->AnyMessages();
|
result = AttachedTransformation()->AnyMessages();
|
||||||
else
|
else
|
||||||
return NumberOfMessages() != 0;
|
result = NumberOfMessages() != 0;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BufferedTransformation::GetNextMessage()
|
bool BufferedTransformation::GetNextMessage()
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->GetNextMessage();
|
result = AttachedTransformation()->GetNextMessage();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CRYPTOPP_ASSERT(!AnyMessages());
|
CRYPTOPP_ASSERT(!AnyMessages());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int BufferedTransformation::SkipMessages(unsigned int count)
|
unsigned int BufferedTransformation::SkipMessages(unsigned int count)
|
||||||
{
|
{
|
||||||
|
unsigned int size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->SkipMessages(count);
|
size = AttachedTransformation()->SkipMessages(count);
|
||||||
else
|
else
|
||||||
return TransferMessagesTo(TheBitBucket(), count);
|
size = TransferMessagesTo(TheBitBucket(), count);
|
||||||
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t BufferedTransformation::TransferMessagesTo2(BufferedTransformation &target, unsigned int &messageCount, const std::string &channel, bool blocking)
|
size_t BufferedTransformation::TransferMessagesTo2(BufferedTransformation &target, unsigned int &messageCount, const std::string &channel, bool blocking)
|
||||||
@ -609,10 +644,10 @@ size_t BufferedTransformation::TransferMessagesTo2(BufferedTransformation &targe
|
|||||||
|
|
||||||
unsigned int BufferedTransformation::CopyMessagesTo(BufferedTransformation &target, unsigned int count, const std::string &channel) const
|
unsigned int BufferedTransformation::CopyMessagesTo(BufferedTransformation &target, unsigned int count, const std::string &channel) const
|
||||||
{
|
{
|
||||||
|
unsigned int size = 0;
|
||||||
if (AttachedTransformation())
|
if (AttachedTransformation())
|
||||||
return AttachedTransformation()->CopyMessagesTo(target, count, channel);
|
size = AttachedTransformation()->CopyMessagesTo(target, count, channel);
|
||||||
else
|
return size;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferedTransformation::SkipAll()
|
void BufferedTransformation::SkipAll()
|
||||||
@ -745,12 +780,12 @@ size_t BufferedTransformation::GetWord32(word32 &value, ByteOrder order)
|
|||||||
return (size_t)Skip(PeekWord32(value, order));
|
return (size_t)Skip(PeekWord32(value, order));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferedTransformation::Attach(BufferedTransformation *newOut)
|
void BufferedTransformation::Attach(BufferedTransformation *newAttachment)
|
||||||
{
|
{
|
||||||
if (AttachedTransformation() && AttachedTransformation()->Attachable())
|
if (AttachedTransformation() && AttachedTransformation()->Attachable())
|
||||||
AttachedTransformation()->Attach(newOut);
|
AttachedTransformation()->Attach(newAttachment);
|
||||||
else
|
else
|
||||||
Detach(newOut);
|
Detach(newAttachment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GeneratableCryptoMaterial::GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize)
|
void GeneratableCryptoMaterial::GenerateRandomWithKeySize(RandomNumberGenerator &rng, unsigned int keySize)
|
||||||
@ -879,10 +914,10 @@ bool PK_Verifier::Verify(PK_MessageAccumulator *messageAccumulator) const
|
|||||||
return VerifyAndRestart(*m);
|
return VerifyAndRestart(*m);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PK_Verifier::VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLength) const
|
bool PK_Verifier::VerifyMessage(const byte *message, size_t messageLen, const byte *signature, size_t signatureLen) const
|
||||||
{
|
{
|
||||||
member_ptr<PK_MessageAccumulator> m(NewVerificationAccumulator());
|
member_ptr<PK_MessageAccumulator> m(NewVerificationAccumulator());
|
||||||
InputSignature(*m, signature, signatureLength);
|
InputSignature(*m, signature, signatureLen);
|
||||||
m->Update(message, messageLen);
|
m->Update(message, messageLen);
|
||||||
return VerifyAndRestart(*m);
|
return VerifyAndRestart(*m);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user