mirror of
https://github.com/shadps4-emu/ext-cryptopp.git
synced 2024-11-23 01:49:41 +00:00
Use unsigned types with UnsignedMin
This commit is contained in:
parent
0b04c12cbe
commit
12c6a9032b
2
ida.cpp
2
ida.cpp
@ -250,7 +250,7 @@ size_t SecretSharing::Put2(const byte *begin, size_t length, int messageEnd, boo
|
||||
if (!blocking)
|
||||
throw BlockingInputOnly("SecretSharing");
|
||||
|
||||
SecByteBlock buf(UnsignedMin(256, length));
|
||||
SecByteBlock buf(UnsignedMin(256u, length));
|
||||
unsigned int threshold = m_ida.GetThreshold();
|
||||
while (length > 0)
|
||||
{
|
||||
|
10
misc.h
10
misc.h
@ -14,6 +14,10 @@
|
||||
#include "stdcpp.h"
|
||||
#include "trap.h"
|
||||
|
||||
#if defined(CRYPTOPP_CXX11)
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
#if !defined(CRYPTOPP_DOXYGEN_PROCESSING)
|
||||
|
||||
#if (CRYPTOPP_MSC_VERSION)
|
||||
@ -695,6 +699,12 @@ template <class T> inline const T& STDMAX(const T& a, const T& b)
|
||||
template <class T1, class T2> inline const T1 UnsignedMin(const T1& a, const T2& b)
|
||||
{
|
||||
CRYPTOPP_COMPILE_ASSERT((sizeof(T1)<=sizeof(T2) && T2(-1)>0) || (sizeof(T1)>sizeof(T2) && T1(-1)>0));
|
||||
|
||||
#if defined(CRYPTOPP_CXX11)
|
||||
CRYPTOPP_COMPILE_ASSERT(std::is_unsigned_v<T1> == true);
|
||||
CRYPTOPP_COMPILE_ASSERT(std::is_unsigned_v<T2> == true);
|
||||
#endif
|
||||
|
||||
if (sizeof(T1)<=sizeof(T2))
|
||||
return b < (T2)a ? (T1)b : a;
|
||||
else
|
||||
|
@ -68,7 +68,7 @@ void RandomPool::GenerateIntoBufferedTransformation(BufferedTransformation &targ
|
||||
do
|
||||
{
|
||||
m_pCipher->ProcessBlock(m_seed);
|
||||
size_t len = UnsignedMin(16, size);
|
||||
size_t len = UnsignedMin(16u, size);
|
||||
target.ChannelPut(channel, m_seed, len);
|
||||
size -= len;
|
||||
} while (size > 0);
|
||||
|
Loading…
Reference in New Issue
Block a user