From a4e4e48127c9dd2b6c10142141e1a3f11caa1cfa Mon Sep 17 00:00:00 2001 From: Alexander Shishenko Date: Sun, 7 Aug 2016 15:54:36 +0300 Subject: [PATCH 1/5] Fixed install path for Windows in CMake (for example, for use with MinGW/MSYS environment) --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb38a9b9..ba47ada3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -286,7 +286,14 @@ set(export_name "cryptopp-targets") # Runtime package if (BUILD_SHARED) - install(TARGETS cryptopp-shared EXPORT ${export_name} DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install( + TARGETS cryptopp-shared + EXPORT ${export_name} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) endif() # Development package From 1e7c837442231a55fab2daa39c353755e1023bc6 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 21 Aug 2016 03:18:26 -0400 Subject: [PATCH 2/5] Add test for Huffman codes (Issue 242) --- validat1.cpp | 33 +++++++++++++++++++++++++++++++++ validate.h | 1 + 2 files changed, 34 insertions(+) diff --git a/validat1.cpp b/validat1.cpp index 44e2779f..3033a0a1 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -87,6 +87,8 @@ bool ValidateAll(bool thorough) pass=TestSecBlock() && pass; // http://github.com/weidai11/cryptopp/issues/64 pass=TestPolynomialMod2() && pass; + // http://github.com/weidai11/cryptopp/pull/242 + pass=TestHuffmanCodes() && pass; #endif pass=ValidateCRC32() && pass; @@ -806,6 +808,37 @@ bool TestSecBlock() } #endif +#if !defined(NDEBUG) && !defined(CRYPTOPP_IMPORTS) +bool TestHuffmanCodes() +{ + cout << "\nTesting Huffman codes...\n\n"; + + static const size_t nCodes = 30; + const unsigned int codeCounts[nCodes] = { + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + + static const unsigned int maxCodeBits = nCodes >> 1; + unsigned int codeBits[nCodes] = { + ~0u, ~0u, ~0u, ~0u, ~0u, + ~0u, ~0u, ~0u, ~0u, ~0u, + ~0u, ~0u, ~0u, ~0u, ~0u, + }; + + try + { + HuffmanEncoder::GenerateCodeLengths(codeBits, maxCodeBits, codeCounts, nCodes); + } + catch(const Exception& ex) + { + return false; + } + + return true; +} +#endif + bool TestOS_RNG() { bool pass = true; diff --git a/validate.h b/validate.h index 6c0c4793..b053216a 100644 --- a/validate.h +++ b/validate.h @@ -91,6 +91,7 @@ bool ValidateESIGN(); #if !defined(NDEBUG) bool TestSecBlock(); bool TestPolynomialMod2(); +bool TestHuffmanCodes(); #endif // Coverity finding From cd3dd25b125de9b467d22f5faeebd7261ec5bdc5 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 21 Aug 2016 04:16:44 -0400 Subject: [PATCH 3/5] Fix compile under VS2010 X86 --- blake2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blake2.cpp b/blake2.cpp index 13923792..7ea6318b 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -25,7 +25,7 @@ NAMESPACE_BEGIN(CryptoPP) // Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. // Also see http://stackoverflow.com/a/38547909/608639 -#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600)) +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER == 1600)) inline __m128i _mm_set_epi64x(const word64 a, const word64 b) { union INT_128_64x2 { From 898d6a3f780e11d7dfc8c2705d17b17ed609dd8a Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 21 Aug 2016 04:36:32 -0400 Subject: [PATCH 4/5] Fix compile under VS2012 X86 --- blake2.cpp | 2 +- validat1.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/blake2.cpp b/blake2.cpp index 7ea6318b..3e655b81 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -25,7 +25,7 @@ NAMESPACE_BEGIN(CryptoPP) // Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. // Also see http://stackoverflow.com/a/38547909/608639 -#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER == 1600)) +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600 && _MSC_VER <= 1700)) inline __m128i _mm_set_epi64x(const word64 a, const word64 b) { union INT_128_64x2 { diff --git a/validat1.cpp b/validat1.cpp index 3033a0a1..4a798dde 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -832,6 +832,7 @@ bool TestHuffmanCodes() } catch(const Exception& ex) { + CRYPTOPP_UNUSED(ex); return false; } From 0c3313c8a2007ecabffc86edfbaef4d312664fff Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 21 Aug 2016 06:42:54 -0400 Subject: [PATCH 5/5] Fix compile under VS2013 X86 --- blake2.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blake2.cpp b/blake2.cpp index 3e655b81..6d409e46 100644 --- a/blake2.cpp +++ b/blake2.cpp @@ -23,9 +23,9 @@ NAMESPACE_BEGIN(CryptoPP) # undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE #endif -// Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. +// Sun Studio 12.3 and earlier lack SSE2's _mm_set_epi64x. Win32 lacks _mm_set_epi64x (Win64 supplies it except for VS2008). // Also see http://stackoverflow.com/a/38547909/608639 -#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600 && _MSC_VER <= 1700)) +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && ((__SUNPRO_CC >= 0x5100 && __SUNPRO_CC < 0x5130) || (_MSC_VER >= 1200 && _MSC_VER < 1600) || (defined(_M_IX86) && _MSC_VER >= 1600)) inline __m128i _mm_set_epi64x(const word64 a, const word64 b) { union INT_128_64x2 {