fix warnings for VC7 and GCC
parent
067b425053
commit
6698a18606
12
Readme.txt
12
Readme.txt
|
|
@ -1,5 +1,5 @@
|
|||
Crypto++: a C++ Class Library of Cryptographic Primitives
|
||||
Version 5.1 (in development)
|
||||
Version 5.1 3/20/2003
|
||||
|
||||
This library includes:
|
||||
|
||||
|
|
@ -242,11 +242,11 @@ History
|
|||
5.01 (special FIPS 140-2 release, in development)
|
||||
- added known answer test for X9.17 RNG in FIPS 140 power-up self test
|
||||
|
||||
5.1 (in development)
|
||||
- added PSS padding and changed PSSR to track IEEE P1363a draft standard
|
||||
5.1 - added PSS padding and changed PSSR to track IEEE P1363a draft standard
|
||||
- added blinding for RSA and Rabin to defend against timing attacks
|
||||
against decryption operations (required API changes for decryption)
|
||||
- fixed a bug in CBC and ECB modes with processing non-aligned data
|
||||
- fixed standard conformance bugs in DLIES (DHAES mode) and RW/EMSA2
|
||||
signature scheme (these fixes are not backwards compatible)
|
||||
- fixed a number of minor bugs and portability problems
|
||||
- removed Sapphire
|
||||
signature scheme (these fixes are not backwards compatible)
|
||||
- fixed a number of minor bugs and portability problems
|
||||
- removed Sapphire
|
||||
|
|
|
|||
|
|
@ -41,9 +41,11 @@ BlumBlumShub::BlumBlumShub(const Integer &p, const Integer &q, const Integer &se
|
|||
|
||||
void BlumBlumShub::Seek(dword index)
|
||||
{
|
||||
Integer e = a_exp_b_mod_c (2, ((index*8) / maxBits + 1), (p-1)*(q-1));
|
||||
Integer i(Integer::POSITIVE, HIGH_WORD(index), word(index));
|
||||
i *= 8;
|
||||
Integer e = a_exp_b_mod_c (2, i / maxBits + 1, (p-1)*(q-1));
|
||||
current = modn.Exponentiate(x0, e);
|
||||
bitsLeft = maxBits - int((index*8) % maxBits);
|
||||
bitsLeft = maxBits - i % maxBits;
|
||||
}
|
||||
|
||||
NAMESPACE_END
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
protected:
|
||||
const ModularArithmetic modn;
|
||||
const int maxBits;
|
||||
const word maxBits;
|
||||
Integer current;
|
||||
int bitsLeft;
|
||||
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ void TestDigestOrMAC(TestData &v, bool testDigest)
|
|||
|
||||
bool GetField(std::istream &is, std::string &name, std::string &value)
|
||||
{
|
||||
name.clear();
|
||||
is >> name;
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
|
@ -293,8 +294,8 @@ bool GetField(std::istream &is, std::string &name, std::string &value)
|
|||
is.ignore(1);
|
||||
|
||||
// VC60 workaround: getline bug
|
||||
char buffer[4];
|
||||
value.resize(0);
|
||||
char buffer[128];
|
||||
value.clear();
|
||||
bool continueLine;
|
||||
|
||||
do
|
||||
|
|
@ -421,7 +422,7 @@ void TestDataFile(const std::string &filename, unsigned int &totalTests, unsigne
|
|||
failedTests++;
|
||||
}
|
||||
else
|
||||
cout << ".";
|
||||
cout << "." << flush;
|
||||
|
||||
totalTests++;
|
||||
}
|
||||
|
|
|
|||
10
ida.cpp
10
ida.cpp
|
|
@ -45,7 +45,7 @@ void RawIDA::ChannelInitialize(const string &channel, const NameValuePairs ¶
|
|||
else
|
||||
{
|
||||
int nShares = parameters.GetIntValueWithDefault("NumberOfShares", m_threshold);
|
||||
for (unsigned int i=0; i<nShares; i++)
|
||||
for (int i=0; i<nShares; i++)
|
||||
AddOutputChannel(i);
|
||||
}
|
||||
|
||||
|
|
@ -93,7 +93,7 @@ unsigned int RawIDA::LookupInputChannel(word32 channelId) const
|
|||
|
||||
void RawIDA::ChannelData(word32 channelId, const byte *inString, unsigned int length, bool messageEnd)
|
||||
{
|
||||
unsigned int i = InsertInputChannel(channelId);
|
||||
int i = InsertInputChannel(channelId);
|
||||
if (i < m_threshold)
|
||||
{
|
||||
unsigned long size = m_inputQueues[i].MaxRetrievable();
|
||||
|
|
@ -125,7 +125,7 @@ void RawIDA::ChannelData(word32 channelId, const byte *inString, unsigned int le
|
|||
|
||||
unsigned int RawIDA::InputBuffered(word32 channelId) const
|
||||
{
|
||||
unsigned int i = LookupInputChannel(channelId);
|
||||
int i = LookupInputChannel(channelId);
|
||||
return i < m_threshold ? m_inputQueues[i].MaxRetrievable() : 0;
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ void RawIDA::PrepareInterpolation()
|
|||
void RawIDA::ProcessInputQueues()
|
||||
{
|
||||
bool finished = (m_channelsFinished == m_threshold);
|
||||
unsigned int i;
|
||||
int i;
|
||||
|
||||
while (finished ? m_channelsReady > 0 : m_channelsReady == m_threshold)
|
||||
{
|
||||
|
|
@ -181,7 +181,7 @@ void RawIDA::ProcessInputQueues()
|
|||
m_channelsReady += queue.NumberOfMessages() > 0 || queue.MaxRetrievable() >= 4;
|
||||
}
|
||||
|
||||
for (i=0; i<m_outputChannelIds.size(); i++)
|
||||
for (i=0; (unsigned int)i<m_outputChannelIds.size(); i++)
|
||||
{
|
||||
if (m_outputToInput[i] != m_threshold)
|
||||
m_outputQueues[i].PutWord32(m_y[m_outputToInput[i]]);
|
||||
|
|
|
|||
|
|
@ -2562,6 +2562,13 @@ Integer::Integer(signed long value)
|
|||
reg[1] = word(SafeRightShift<WORD_BITS, unsigned long>(value));
|
||||
}
|
||||
|
||||
Integer::Integer(Sign s, word high, word low)
|
||||
: reg(2), sign(s)
|
||||
{
|
||||
reg[0] = low;
|
||||
reg[1] = high;
|
||||
}
|
||||
|
||||
bool Integer::IsConvertableToLong() const
|
||||
{
|
||||
if (ByteCount() > sizeof(long))
|
||||
|
|
|
|||
|
|
@ -66,6 +66,9 @@ public:
|
|||
RandomNumberNotFound() : Exception(OTHER_ERROR, "Integer: no integer satisfies the given parameters") {}
|
||||
};
|
||||
|
||||
//!
|
||||
enum Sign {POSITIVE=0, NEGATIVE=1};
|
||||
|
||||
//!
|
||||
enum Signedness {
|
||||
//!
|
||||
|
|
@ -92,6 +95,9 @@ public:
|
|||
//! convert from signed long
|
||||
Integer(signed long value);
|
||||
|
||||
//! convert from two words
|
||||
Integer(Sign s, word highWord, word lowWord);
|
||||
|
||||
//! convert from string
|
||||
/*! str can be in base 2, 8, 10, or 16. Base is determined by a
|
||||
case insensitive suffix of 'h', 'o', or 'b'. No suffix means base 10.
|
||||
|
|
@ -390,8 +396,6 @@ private:
|
|||
friend void PositiveMultiply(Integer &product, const Integer &a, const Integer &b);
|
||||
friend void PositiveDivide(Integer &remainder, Integer "ient, const Integer ÷nd, const Integer &divisor);
|
||||
|
||||
enum Sign {POSITIVE=0, NEGATIVE=1};
|
||||
|
||||
SecAlignedWordBlock reg;
|
||||
Sign sign;
|
||||
};
|
||||
|
|
|
|||
6
pssr.cpp
6
pssr.cpp
|
|
@ -68,7 +68,7 @@ void PSSR_MEM_Base::ComputeMessageRepresentative(RandomNumberGenerator &rng,
|
|||
memcpy(representative + representativeByteLength - u, hashIdentifier.first, hashIdentifier.second);
|
||||
representative[representativeByteLength - 1] = hashIdentifier.second ? 0xcc : 0xbc;
|
||||
if (representativeBitLength % 8 != 0)
|
||||
representative[0] = Crop(representative[0], representativeBitLength % 8);
|
||||
representative[0] = (byte)Crop(representative[0], representativeBitLength % 8);
|
||||
}
|
||||
|
||||
DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative(
|
||||
|
|
@ -94,12 +94,12 @@ DecodingResult PSSR_MEM_Base::RecoverMessageFromRepresentative(
|
|||
|
||||
GetMGF().GenerateAndMask(hash, representative, representativeByteLength - u - digestSize, h, digestSize);
|
||||
if (representativeBitLength % 8 != 0)
|
||||
representative[0] = Crop(representative[0], representativeBitLength % 8);
|
||||
representative[0] = (byte)Crop(representative[0], representativeBitLength % 8);
|
||||
|
||||
// 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));
|
||||
if (*M == 0x01 && M - representative - (representativeBitLength % 8 != 0) >= MinPadLen(digestSize))
|
||||
if (*M == 0x01 && (unsigned int)(M - representative - (representativeBitLength % 8 != 0)) >= MinPadLen(digestSize))
|
||||
{
|
||||
recoverableMessageLength = salt-M-1;
|
||||
memcpy(recoverableMessage, M+1, recoverableMessageLength);
|
||||
|
|
|
|||
8
rsa.cpp
8
rsa.cpp
|
|
@ -26,17 +26,17 @@ void RSA_TestInstantiations()
|
|||
RSASS<PKCS1v15, SHA>::Verifier x3(x2);
|
||||
RSASS<PKCS1v15, SHA>::Verifier x4(x2.GetKey());
|
||||
RSASS<PSS, SHA>::Verifier x5(x3);
|
||||
#ifndef __MWERKS__
|
||||
RSASS<PSSR, SHA>::Signer x6 = x2;
|
||||
x3 = x2;
|
||||
x6 = x2;
|
||||
#endif
|
||||
RSAES<PKCS1v15>::Encryptor x7(x2);
|
||||
#ifndef __GNUC__
|
||||
RSAES<PKCS1v15>::Encryptor x8(x3);
|
||||
#endif
|
||||
RSAES<OAEP<SHA> >::Encryptor x9(x2);
|
||||
|
||||
x6 = x2;
|
||||
#ifndef __MWERKS__
|
||||
x3 = x2;
|
||||
#endif
|
||||
x4 = x2.GetKey();
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
4
seal.cpp
4
seal.cpp
|
|
@ -77,8 +77,8 @@ void SEAL_Policy<B>::CipherResynchronize(byte *keystreamBuffer, const byte *IV)
|
|||
template <class B>
|
||||
void SEAL_Policy<B>::SeekToIteration(dword iterationCount)
|
||||
{
|
||||
m_outsideCounter = m_startCount + iterationCount / m_iterationsPerCount;
|
||||
m_insideCounter = iterationCount % m_iterationsPerCount;
|
||||
m_outsideCounter = m_startCount + (unsigned int)(iterationCount / m_iterationsPerCount);
|
||||
m_insideCounter = (unsigned int)(iterationCount % m_iterationsPerCount);
|
||||
}
|
||||
|
||||
template <class B>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ static word64 SHARKTransform(word64 a)
|
|||
GF256 gf256(0xf5);
|
||||
for (unsigned int i=0; i<8; i++)
|
||||
for(unsigned int j=0; j<8; j++)
|
||||
result ^= word64(gf256.Multiply(iG[i][j], a>>(56-8*j))) << (56-8*i);
|
||||
result ^= word64(gf256.Multiply(iG[i][j], GF256::Element(a>>(56-8*j)))) << (56-8*i);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ void AdditiveCipherTemplate<BASE>::Seek(dword position)
|
|||
if (position > 0)
|
||||
{
|
||||
policy.WriteKeystream(m_buffer, 1);
|
||||
m_leftOver = bytesPerIteration - position;
|
||||
m_leftOver = bytesPerIteration - (unsigned int)position;
|
||||
}
|
||||
else
|
||||
m_leftOver = 0;
|
||||
|
|
|
|||
4
test.cpp
4
test.cpp
|
|
@ -638,7 +638,7 @@ void SecretShareFile(int threshold, int nShares, const char *filename, const cha
|
|||
|
||||
vector_member_ptrs<FileSink> fileSinks(nShares);
|
||||
string channel;
|
||||
for (unsigned int i=0; i<nShares; i++)
|
||||
for (int i=0; i<nShares; i++)
|
||||
{
|
||||
char extension[5] = ".000";
|
||||
extension[1]='0'+byte(i/100);
|
||||
|
|
@ -662,7 +662,7 @@ void SecretRecoverFile(int threshold, const char *outFilename, char *const *inFi
|
|||
|
||||
vector_member_ptrs<FileSource> fileSources(threshold);
|
||||
SecByteBlock channel(4);
|
||||
unsigned int i;
|
||||
int i;
|
||||
for (i=0; i<threshold; i++)
|
||||
{
|
||||
fileSources[i].reset(new FileSource(inFilenames[i], false));
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ bool TestOS_RNG()
|
|||
time_t t = time(NULL), t1 = 0;
|
||||
|
||||
// check that it doesn't take too long to generate a reasonable amount of randomness
|
||||
while (total < 16 && (t1 < 10 || total*8 > t1))
|
||||
while (total < 16 && (t1 < 10 || total*8 > (unsigned long)t1))
|
||||
{
|
||||
test.Pump(1);
|
||||
total += 1;
|
||||
|
|
|
|||
4
wait.cpp
4
wait.cpp
|
|
@ -94,7 +94,7 @@ DWORD WINAPI WaitingThread(LPVOID lParam)
|
|||
handles[0] = thread.stopWaiting;
|
||||
std::copy(thread.waitHandles, thread.waitHandles+thread.count, handles.begin()+1);
|
||||
|
||||
DWORD result = ::WaitForMultipleObjects(handles.size(), handles.begin(), FALSE, INFINITE);
|
||||
DWORD result = ::WaitForMultipleObjects(handles.size(), &handles[0], FALSE, INFINITE);
|
||||
|
||||
if (result == WAIT_OBJECT_0)
|
||||
continue; // another thread finished waiting first, so do nothing
|
||||
|
|
@ -154,7 +154,7 @@ bool WaitObjectContainer::Wait(unsigned long milliseconds)
|
|||
Sleep(0);
|
||||
if (i<nThreads)
|
||||
{
|
||||
thread.waitHandles = m_handles.begin() + i*WAIT_OBJECTS_PER_THREAD;
|
||||
thread.waitHandles = &m_handles[i*WAIT_OBJECTS_PER_THREAD];
|
||||
thread.count = STDMIN(WAIT_OBJECTS_PER_THREAD, m_handles.size() - i*WAIT_OBJECTS_PER_THREAD);
|
||||
thread.error = &error;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue