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 diff --git a/blake2.cpp b/blake2.cpp index 13923792..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)) +#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 { diff --git a/validat1.cpp b/validat1.cpp index 9fb1b3de..a7a464c4 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; @@ -808,6 +810,38 @@ 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) + { + CRYPTOPP_UNUSED(ex); + return false; + } + + return true; +} +#endif + bool TestOS_RNG() { bool pass = true; diff --git a/validate.h b/validate.h index 0a388308..14472835 100644 --- a/validate.h +++ b/validate.h @@ -93,6 +93,7 @@ bool ValidateESIGN(); #if !defined(NDEBUG) bool TestSecBlock(); bool TestPolynomialMod2(); +bool TestHuffmanCodes(); #endif // Coverity finding