From 033f204a869972d26b0c2e32b732d8e2834dbfaf Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 27 Aug 2019 14:44:27 -0400 Subject: [PATCH] Fix .Net 2002 compile This testing occurs on Windows XP. We are still rockin it --- cryptest.nmake | 12 ++++++------ cryptlib.cpp | 1 - donna_sse.cpp | 6 +++--- keccak.h | 2 -- osrng.cpp | 5 ++++- sha3.h | 2 -- shake.h | 2 -- test.cpp | 2 +- 8 files changed, 14 insertions(+), 18 deletions(-) diff --git a/cryptest.nmake b/cryptest.nmake index 40294ac9..f09a4a9e 100644 --- a/cryptest.nmake +++ b/cryptest.nmake @@ -264,13 +264,13 @@ clean :: $(RM) /F /Q pch.obj $(LIB_OBJS) $(ASM_OBJS) $(TEST_OBJS) *.pdb 2>nul distclean :: clean -!IF EXIST ($(USERNAME).sdf) - attrib -r -a -s -h $(USERNAME).sdf 2>nul - $(RM) /F /Q $(USERNAME).sdf 2>nul +!IF EXIST ("$(USERNAME).sdf") + attrib -r -a -s -h "$(USERNAME).sdf" 2>nul + $(RM) /F /Q "$(USERNAME).sdf" 2>nul !ENDIF -!IF EXIST ($(USERNAME).suo) - attrib -r -a -s -h $(USERNAME).suo 2>nul - $(RM) /F /Q $(USERNAME).suo 2>nul +!IF EXIST ("$(USERNAME).suo") + attrib -r -a -s -h $(USERNAME).suo" 2>nul + $(RM) /F /Q $(USERNAME).suo" 2>nul !ENDIF !IF EXIST (Win32\) $(RMDIR) Win32\ /q /s 2>nul diff --git a/cryptlib.cpp b/cryptlib.cpp index 173c6d10..e248935a 100644 --- a/cryptlib.cpp +++ b/cryptlib.cpp @@ -29,7 +29,6 @@ NAMESPACE_BEGIN(CryptoPP) -CRYPTOPP_COMPILE_ASSERT(SIZE_MAX > 0); CRYPTOPP_COMPILE_ASSERT(sizeof(byte) == 1); CRYPTOPP_COMPILE_ASSERT(sizeof(word16) == 2); CRYPTOPP_COMPILE_ASSERT(sizeof(word32) == 4); diff --git a/donna_sse.cpp b/donna_sse.cpp index 410afbc4..d619e89a 100644 --- a/donna_sse.cpp +++ b/donna_sse.cpp @@ -1059,13 +1059,13 @@ int curve25519_mult_SSE2(byte sharedKey[32], const byte secretKey[32], const byt packed32bignum25519 qx, qz, pqz, pqx; packed64bignum25519 nq, sq, sqscalar, prime, primex, primez, nqpq; bignum25519mulprecomp preq; - size_t i=0, bit=0, lastbit=0; + size_t bit=0, lastbit=0; curve25519_expand(nqpqx, othersKey); curve25519_mul_precompute(&preq, nqpqx); /* do bits 254..3 */ - for (i = 254, lastbit=0; i >= 3; i--) { + for (size_t i = 254, lastbit=0; i >= 3; i--) { bit = (e[i/8] >> (i & 7)) & 1; curve25519_swap_conditional(nqx, nqpqx, (word32)(bit ^ lastbit)); curve25519_swap_conditional(nqz, nqpqz, (word32)(bit ^ lastbit)); @@ -1098,7 +1098,7 @@ int curve25519_mult_SSE2(byte sharedKey[32], const byte secretKey[32], const byt curve25519_swap_conditional(nqz, nqpqz, (word32)bit); /* do bits 2..0 */ - for (i = 0; i < 3; i++) { + for (size_t i = 0; i < 3; i++) { curve25519_compute_nq(nq, nqx, nqz); curve25519_square_packed64(sq, nq); /* sq = nq^2 */ curve25519_121665_packed64(sqscalar, sq); /* sqscalar = sq * [121666,121665] */ diff --git a/keccak.h b/keccak.h index 75410ba7..674ac1fe 100644 --- a/keccak.h +++ b/keccak.h @@ -94,8 +94,6 @@ private: #if !defined(__BORLANDC__) // ensure there was no underflow in the math CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE < 200); - // this is a general expectation by HMAC - CRYPTOPP_COMPILE_ASSERT((int)BLOCKSIZE > (int)DIGESTSIZE); #endif }; diff --git a/osrng.cpp b/osrng.cpp index 50821471..a8b13329 100644 --- a/osrng.cpp +++ b/osrng.cpp @@ -24,6 +24,9 @@ #ifdef CRYPTOPP_WIN32_AVAILABLE #define WIN32_LEAN_AND_MEAN #include +#ifndef ERROR_INCORRECT_SIZE +# define ERROR_INCORRECT_SIZE 0x000005B6 +#endif #if defined(USE_MS_CRYPTOAPI) #include #ifndef CRYPT_NEWKEYSET @@ -44,7 +47,7 @@ # define STATUS_INVALID_HANDLE 0xC0000008 #endif #endif -#endif +#endif // Win32 #ifdef CRYPTOPP_UNIX_AVAILABLE #include diff --git a/sha3.h b/sha3.h index ea412166..d8993f07 100644 --- a/sha3.h +++ b/sha3.h @@ -82,8 +82,6 @@ private: #if !defined(__BORLANDC__) // ensure there was no underflow in the math CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE < 200); - // this is a general expectation by HMAC - CRYPTOPP_COMPILE_ASSERT((int)BLOCKSIZE > (int)DIGESTSIZE); #endif }; diff --git a/shake.h b/shake.h index 37cb8274..8c4a0092 100644 --- a/shake.h +++ b/shake.h @@ -93,8 +93,6 @@ private: #if !defined(__BORLANDC__) // ensure there was no underflow in the math CRYPTOPP_COMPILE_ASSERT(BLOCKSIZE < 200); - // this is a general expectation by HMAC - CRYPTOPP_COMPILE_ASSERT((int)BLOCKSIZE > (int)DIGESTSIZE); #endif }; diff --git a/test.cpp b/test.cpp index 7a483f6a..be72405e 100644 --- a/test.cpp +++ b/test.cpp @@ -507,7 +507,7 @@ void SetArgvPathHint(const char* argv0, std::string& pathHint) #if defined(AT_EXECFN) if (getauxval(AT_EXECFN)) pathHint = getauxval(AT_EXECFN); -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && (_MSC_VER > 1310) char* pgmptr = NULLPTR; errno_t err = _get_pgmptr(&pgmptr); if (err == 0 && pgmptr != NULLPTR)