From ff7f40cabea7377bef1f9e79ca81095ed1b35910 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 23 May 2017 23:00:58 -0400 Subject: [PATCH 01/49] Cleared C4505 under MSVC (Issue 412) --- eccrypto.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eccrypto.cpp b/eccrypto.cpp index 6c384597..92106052 100644 --- a/eccrypto.cpp +++ b/eccrypto.cpp @@ -6,7 +6,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189) +# pragma warning(disable: 4127 4189 4505) #endif #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE From 34ac34c0b4498a6c7fc51926621a0cdd98b100a1 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 23 May 2017 23:03:47 -0400 Subject: [PATCH 02/49] Cleared C4459 under MSVC (Issue 412) --- kalyna.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/kalyna.cpp b/kalyna.cpp index eba64846..53af0399 100644 --- a/kalyna.cpp +++ b/kalyna.cpp @@ -40,7 +40,7 @@ using CryptoPP::KalynaTab::IS; template inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB]) { -#if defined(IS_BIG_ENDIAN) +#if defined(IU_BIG_ENDIAN) if (NB == 2) { oddkey[0] = (evenkey[1] << 8) | (evenkey[0] >> 56); @@ -67,17 +67,17 @@ inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB]) } else { - CRYPTOPP_ASSERT(0); + CRYPVOPP_AUUERV(0); } #else - static const unsigned int S = (NB == 2) ? 16 : (NB == 4) ? 32 : (NB == 8) ? 64 : -1; - static const unsigned int T = (NB == 2) ? 7 : (NB == 4) ? 11 : (NB == 8) ? 19 : -1; + static const unsigned int U = (NB == 2) ? 16 : (NB == 4) ? 32 : (NB == 8) ? 64 : -1; + static const unsigned int V = (NB == 2) ? 7 : (NB == 4) ? 11 : (NB == 8) ? 19 : -1; const byte* even = reinterpret_cast(evenkey); byte* odd = reinterpret_cast(oddkey); - memcpy(odd, even + T, S - T); - memcpy(odd + S - T, even, T); + memcpy(odd, even + V, U - V); + memcpy(odd + U - V, even, V); #endif } From 830c06e922e4d53c31b27a5de447556217181d0e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 23 May 2017 23:05:31 -0400 Subject: [PATCH 03/49] Fixed copy/paste typo --- kalyna.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kalyna.cpp b/kalyna.cpp index 53af0399..f4c3cc0e 100644 --- a/kalyna.cpp +++ b/kalyna.cpp @@ -40,7 +40,7 @@ using CryptoPP::KalynaTab::IS; template inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB]) { -#if defined(IU_BIG_ENDIAN) +#if defined(IS_BIG_ENDIAN) if (NB == 2) { oddkey[0] = (evenkey[1] << 8) | (evenkey[0] >> 56); @@ -67,7 +67,7 @@ inline void MakeOddKey(const word64 evenkey[NB], word64 oddkey[NB]) } else { - CRYPVOPP_AUUERV(0); + CRYPTOPP_ASSERT(0); } #else static const unsigned int U = (NB == 2) ? 16 : (NB == 4) ? 32 : (NB == 8) ? 64 : -1; From b65ec291ea96edfdd16b7e9c6d7d848962e6e3f5 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 25 May 2017 00:04:45 -0400 Subject: [PATCH 04/49] Updated test script --- TestScripts/cryptest.sh | 103 ++++++++++++++++++++++++++++++++++++---- cryptest.sh | 103 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 188 insertions(+), 18 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index 51ad51c6..26549f01 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -88,8 +88,12 @@ IS_FREEBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c freebsd) IS_NETBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c netbsd) IS_SOLARIS=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c sunos) +IS_DEBIAN=$(lsb_release -a 2>&1 | "$GREP" -i -c debian) +IS_FEDORA=$(lsb_release -a 2>&1 | "$GREP" -i -c fedora) +IS_UBUNTU=$(lsb_release -a 2>&1 | "$GREP" -i -c ubuntu) + THIS_MACHINE=$(uname -m 2>&1) -IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i586|i686)") +IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i686|i686)") IS_X64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(amd64|x86_64)") IS_PPC=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(Power|PPC)") IS_ARM32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$EGREP" -i -c "(arm|aarch32)") @@ -1703,23 +1707,104 @@ if [[ ("${#PLATFORM_CXXFLAGS[@]}" -ne "0") ]]; then fi fi +############################################ +# Debian specific. +if [[ ("$IS_DEBIAN" -ne "0" || "$IS_UBUNTU" -ne "0") ]]; then + + # Flags taken from Debian's build logs + # https://buildd.debian.org/status/fetch.php?pkg=libcrypto%2b%2b&arch=i386&ver=5.6.4-6 + # https://buildd.debian.org/status/fetch.php?pkg=libcrypto%2b%2b&arch=kfreebsd-amd64&ver=5.6.4-6&stamp=1482663138 + + DEBIAN_FLAGS=("-DHAVE_CONFIG_H" "-I." "-Wdate-time" "-D_FORTIFY_SOURCE=2" "-g" "-O2" + "-fstack-protector-strong" "-Wformat -Werror=format-security" "-DCRYPTOPP_INIT_PRIORITY=250" + "-DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS" "-DNDEBUG" "-fPIC" "-DPIC") + + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Debian standard build" | tee -a "$TEST_RESULTS" + echo + + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXX="g++" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="${DEBIAN_FLAGS[*]}" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi +fi + +############################################ +# Fedora specific. +if [[ ("$IS_FEDORA" -ne "0") ]]; then + + # Flags taken from Fedora's build logs + # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/i686/build.log + # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/x86_64/build.log + if [[ ("$IS_X86" -ne "0") ]]; then + MARCH_OPT=(-m32 -march=i686) + else + MARCH_OPT=(-m64 -mtune=generic) + fi + + FEDORA_FLAGS=("-DHAVE_CONFIG_H" "-I." "-O2" "-g" "-pipe" "-Wall" "-Werror=format-security" "-fPIC" "-DPIC" + "-Wp,-D_FORTIFY_SOURCE=2" "-fexceptions" "-fstack-protector-strong" "--param=ssp-buffer-size=4" + "-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1" "${MARCH_OPT[@]}" "-fasynchronous-unwind-tables") + + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Fedora standard build" | tee -a "$TEST_RESULTS" + echo + + if [[ ! -f /usr/lib/rpm/redhat/redhat-hardened-cc1 ]]; then + echo "ERROR: please install redhat-rpm-config package" + else + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXX="g++" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="${FEDORA_FLAGS[*]}" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi + fi +fi + ############################################ # Minimum platform if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" -ne "0") ]]; then - # i586 (lacks MMX, SSE and SSE2) + # i686 (lacks MMX, SSE and SSE2) if [[ "$IS_X86" -ne "0" ]]; then ############################################ # Debug build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Debug, i586 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" + echo "Testing: Debug, i686 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$DEBUG_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$DEBUG_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="$CXXFLAGS" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then @@ -1739,13 +1824,13 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" # Release build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Release, i586 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" + echo "Testing: Release, i686 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$RELEASE_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$RELEASE_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="$CXXFLAGS" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then @@ -1822,7 +1907,7 @@ fi # Mismatched arch capabilities if [[ ( ("$IS_X86" -ne "0" || "$IS_X32" -ne "0" || "$IS_X64" -ne "0") && "$HAVE_NATIVE_ARCH" -ne "0") ]]; then - # i586 (lacks MMX, SSE and SSE2) + # i686 (lacks MMX, SSE and SSE2) if [[ "$IS_X86" -ne "0" ]]; then ############################################ # Debug build @@ -1834,7 +1919,7 @@ if [[ ( ("$IS_X86" -ne "0" || "$IS_X32" -ne "0" || "$IS_X64" -ne "0") && "$HAVE_ "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$DEBUG_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$DEBUG_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" static 2>&1 | tee -a "$TEST_RESULTS" # The makefile may add -DCRYPTOPP_DISABLE_XXX, so we can't add -march=native @@ -1864,7 +1949,7 @@ if [[ ( ("$IS_X86" -ne "0" || "$IS_X32" -ne "0" || "$IS_X64" -ne "0") && "$HAVE_ "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$RELEASE_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$RELEASE_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" static 2>&1 | tee -a "$TEST_RESULTS" # The makefile may add -DCRYPTOPP_DISABLE_XXX, so we can't add -march=native diff --git a/cryptest.sh b/cryptest.sh index 51ad51c6..26549f01 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -88,8 +88,12 @@ IS_FREEBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c freebsd) IS_NETBSD=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c netbsd) IS_SOLARIS=$(echo -n "$THIS_SYSTEM" | "$GREP" -i -c sunos) +IS_DEBIAN=$(lsb_release -a 2>&1 | "$GREP" -i -c debian) +IS_FEDORA=$(lsb_release -a 2>&1 | "$GREP" -i -c fedora) +IS_UBUNTU=$(lsb_release -a 2>&1 | "$GREP" -i -c ubuntu) + THIS_MACHINE=$(uname -m 2>&1) -IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i586|i686)") +IS_X86=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(i386|i486|i686|i686)") IS_X64=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(amd64|x86_64)") IS_PPC=$(echo -n "$THIS_MACHINE" | "$EGREP" -i -c "(Power|PPC)") IS_ARM32=$(echo -n "$THIS_MACHINE" | "$GREP" -v "64" | "$EGREP" -i -c "(arm|aarch32)") @@ -1703,23 +1707,104 @@ if [[ ("${#PLATFORM_CXXFLAGS[@]}" -ne "0") ]]; then fi fi +############################################ +# Debian specific. +if [[ ("$IS_DEBIAN" -ne "0" || "$IS_UBUNTU" -ne "0") ]]; then + + # Flags taken from Debian's build logs + # https://buildd.debian.org/status/fetch.php?pkg=libcrypto%2b%2b&arch=i386&ver=5.6.4-6 + # https://buildd.debian.org/status/fetch.php?pkg=libcrypto%2b%2b&arch=kfreebsd-amd64&ver=5.6.4-6&stamp=1482663138 + + DEBIAN_FLAGS=("-DHAVE_CONFIG_H" "-I." "-Wdate-time" "-D_FORTIFY_SOURCE=2" "-g" "-O2" + "-fstack-protector-strong" "-Wformat -Werror=format-security" "-DCRYPTOPP_INIT_PRIORITY=250" + "-DCRYPTOPP_NO_UNALIGNED_DATA_ACCESS" "-DNDEBUG" "-fPIC" "-DPIC") + + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Debian standard build" | tee -a "$TEST_RESULTS" + echo + + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXX="g++" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="${DEBIAN_FLAGS[*]}" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi +fi + +############################################ +# Fedora specific. +if [[ ("$IS_FEDORA" -ne "0") ]]; then + + # Flags taken from Fedora's build logs + # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/i686/build.log + # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/x86_64/build.log + if [[ ("$IS_X86" -ne "0") ]]; then + MARCH_OPT=(-m32 -march=i686) + else + MARCH_OPT=(-m64 -mtune=generic) + fi + + FEDORA_FLAGS=("-DHAVE_CONFIG_H" "-I." "-O2" "-g" "-pipe" "-Wall" "-Werror=format-security" "-fPIC" "-DPIC" + "-Wp,-D_FORTIFY_SOURCE=2" "-fexceptions" "-fstack-protector-strong" "--param=ssp-buffer-size=4" + "-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1" "${MARCH_OPT[@]}" "-fasynchronous-unwind-tables") + + echo + echo "************************************" | tee -a "$TEST_RESULTS" + echo "Testing: Fedora standard build" | tee -a "$TEST_RESULTS" + echo + + if [[ ! -f /usr/lib/rpm/redhat/redhat-hardened-cc1 ]]; then + echo "ERROR: please install redhat-rpm-config package" + else + "$MAKE" clean > /dev/null 2>&1 + rm -f adhoc.cpp > /dev/null 2>&1 + + CXX="g++" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="${FEDORA_FLAGS[*]}" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" + + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to make cryptest.exe" | tee -a "$TEST_RESULTS" + else + ./cryptest.exe v 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute validation suite" | tee -a "$TEST_RESULTS" + fi + ./cryptest.exe tv all 2>&1 | tee -a "$TEST_RESULTS" + if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then + echo "ERROR: failed to execute test vectors" | tee -a "$TEST_RESULTS" + fi + fi + fi +fi + ############################################ # Minimum platform if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" -ne "0") ]]; then - # i586 (lacks MMX, SSE and SSE2) + # i686 (lacks MMX, SSE and SSE2) if [[ "$IS_X86" -ne "0" ]]; then ############################################ # Debug build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Debug, i586 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" + echo "Testing: Debug, i686 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$DEBUG_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$DEBUG_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="$CXXFLAGS" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then @@ -1739,13 +1824,13 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" # Release build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Release, i586 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" + echo "Testing: Release, i686 minimum arch CXXFLAGS" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$RELEASE_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$RELEASE_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" "$MAKE" "${MAKEARGS[@]}" CXXFLAGS="$CXXFLAGS" static dynamic cryptest.exe 2>&1 | tee -a "$TEST_RESULTS" if [[ ("${PIPESTATUS[0]}" -ne "0") ]]; then @@ -1822,7 +1907,7 @@ fi # Mismatched arch capabilities if [[ ( ("$IS_X86" -ne "0" || "$IS_X32" -ne "0" || "$IS_X64" -ne "0") && "$HAVE_NATIVE_ARCH" -ne "0") ]]; then - # i586 (lacks MMX, SSE and SSE2) + # i686 (lacks MMX, SSE and SSE2) if [[ "$IS_X86" -ne "0" ]]; then ############################################ # Debug build @@ -1834,7 +1919,7 @@ if [[ ( ("$IS_X86" -ne "0" || "$IS_X32" -ne "0" || "$IS_X64" -ne "0") && "$HAVE_ "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$DEBUG_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$DEBUG_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" static 2>&1 | tee -a "$TEST_RESULTS" # The makefile may add -DCRYPTOPP_DISABLE_XXX, so we can't add -march=native @@ -1864,7 +1949,7 @@ if [[ ( ("$IS_X86" -ne "0" || "$IS_X32" -ne "0" || "$IS_X64" -ne "0") && "$HAVE_ "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 - CXXFLAGS="$RELEASE_CXXFLAGS -march=i586 $OPT_PIC" + CXXFLAGS="$RELEASE_CXXFLAGS -march=i686 $OPT_PIC" CXX="$CXX" CXXFLAGS="$CXXFLAGS" "$MAKE" "${MAKEARGS[@]}" static 2>&1 | tee -a "$TEST_RESULTS" # The makefile may add -DCRYPTOPP_DISABLE_XXX, so we can't add -march=native From 3b56ba118f34968b1281e14bd45d78b8f03af288 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 25 May 2017 06:20:00 -0400 Subject: [PATCH 05/49] Avoid extra ByteReverse This gains about 0.6 cpb. SHA-1 is down to 1.9 cpb. SHA-256 is not affected --- iterhash.cpp | 11 +++++++---- sha.cpp | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/iterhash.cpp b/iterhash.cpp index 722d4f77..ce2e5cc3 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -82,11 +82,14 @@ template byte * IteratedHashBase::CreateUpdateSpa template size_t IteratedHashBase::HashMultipleBlocks(const T *input, size_t length) { - // Hardware based SHA1 and SHA256 correct blocks themselves due to hardware requirements. - // For Intel, SHA1 will effectively call ByteReverse(). SHA256 formats data to Intel - // requirements, which means eight words ABCD EFGH are transformed to ABEF CDGH. +#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE + // SHA-1 and SHA-256 only + static const bool noReverse = HasSHA() && this->BlockSize() <= 64; +#else + const bool noReverse = NativeByteOrderIs(this->GetByteOrder()); +#endif + unsigned int blockSize = this->BlockSize(); - bool noReverse = NativeByteOrderIs(this->GetByteOrder()); T* dataBuf = this->DataBuf(); do { diff --git a/sha.cpp b/sha.cpp index f64ff33d..2c7f32a6 100644 --- a/sha.cpp +++ b/sha.cpp @@ -112,7 +112,7 @@ static void SHA1_SSE_SHA_Transform(word32 *state, const word32 *data) ABCD = _mm_loadu_si128((__m128i*) state); E0 = _mm_set_epi32(state[4], 0, 0, 0); ABCD = _mm_shuffle_epi32(ABCD, 0x1B); - MASK = _mm_set_epi8(3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12); + MASK = _mm_set_epi8(0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15); // Save current hash ABCD_SAVE = ABCD; From b447a7bf1561c222fa1d299adfaf2510a5ad3203 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 25 May 2017 06:26:43 -0400 Subject: [PATCH 06/49] Add missing header --- iterhash.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/iterhash.cpp b/iterhash.cpp index ce2e5cc3..f8be97d9 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -6,6 +6,7 @@ #include "iterhash.h" #include "misc.h" +#include "cpu.h" NAMESPACE_BEGIN(CryptoPP) From bd7aa155a6c78e6e4381b883ccfca7c6ad1ad983 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Thu, 25 May 2017 06:46:40 -0400 Subject: [PATCH 07/49] Revert "Avoid extra ByteReverse" This reverts commit 3b56ba118f34. It broke Tiger and SEAL. Arg... --- iterhash.cpp | 11 ++++------- sha.cpp | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/iterhash.cpp b/iterhash.cpp index f8be97d9..bdc99ec5 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -83,14 +83,11 @@ template byte * IteratedHashBase::CreateUpdateSpa template size_t IteratedHashBase::HashMultipleBlocks(const T *input, size_t length) { -#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE - // SHA-1 and SHA-256 only - static const bool noReverse = HasSHA() && this->BlockSize() <= 64; -#else - const bool noReverse = NativeByteOrderIs(this->GetByteOrder()); -#endif - + // Hardware based SHA1 and SHA256 correct blocks themselves due to hardware requirements. + // For Intel, SHA1 will effectively call ByteReverse(). SHA256 formats data to Intel + // requirements, which means eight words ABCD EFGH are transformed to ABEF CDGH. unsigned int blockSize = this->BlockSize(); + bool noReverse = NativeByteOrderIs(this->GetByteOrder()); T* dataBuf = this->DataBuf(); do { diff --git a/sha.cpp b/sha.cpp index 2c7f32a6..f64ff33d 100644 --- a/sha.cpp +++ b/sha.cpp @@ -112,7 +112,7 @@ static void SHA1_SSE_SHA_Transform(word32 *state, const word32 *data) ABCD = _mm_loadu_si128((__m128i*) state); E0 = _mm_set_epi32(state[4], 0, 0, 0); ABCD = _mm_shuffle_epi32(ABCD, 0x1B); - MASK = _mm_set_epi8(0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15); + MASK = _mm_set_epi8(3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12); // Save current hash ABCD_SAVE = ABCD; From de1270656c275074dfc6c013484c157e9d62277b Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 01:51:44 -0400 Subject: [PATCH 08/49] Avoid extra ByteReverse when using Intel SHA extensions This gains about 0.6 cpb. SHA-1 is down to 1.7 to 1.9 cpb. SHA-256 is not affected --- iterhash.cpp | 3 --- seal.cpp | 8 +++++++- sha.cpp | 28 ++++++++++++++++++++++++++-- sha.h | 3 +++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/iterhash.cpp b/iterhash.cpp index bdc99ec5..eedd5172 100644 --- a/iterhash.cpp +++ b/iterhash.cpp @@ -83,9 +83,6 @@ template byte * IteratedHashBase::CreateUpdateSpa template size_t IteratedHashBase::HashMultipleBlocks(const T *input, size_t length) { - // Hardware based SHA1 and SHA256 correct blocks themselves due to hardware requirements. - // For Intel, SHA1 will effectively call ByteReverse(). SHA256 formats data to Intel - // requirements, which means eight words ABCD EFGH are transformed to ABEF CDGH. unsigned int blockSize = this->BlockSize(); bool noReverse = NativeByteOrderIs(this->GetByteOrder()); T* dataBuf = this->DataBuf(); diff --git a/seal.cpp b/seal.cpp index acc4e4e5..4108feb5 100644 --- a/seal.cpp +++ b/seal.cpp @@ -4,6 +4,7 @@ #include "pch.h" #include "seal.h" +#include "cpu.h" #include "sha.h" #include "misc.h" #include "secblock.h" @@ -37,11 +38,16 @@ word32 SEAL_Gamma::Apply(word32 i) word32 shaIndex = i/5; if (shaIndex != lastIndex) { - memcpy(Z, H, 20); +#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE + D[0] = ConditionalByteReverse(HasSHA() ? BIG_ENDIAN_ORDER : LITTLE_ENDIAN_ORDER, shaIndex); +#else D[0] = shaIndex; +#endif + memcpy(Z, H, 20); SHA1::Transform(Z, D); lastIndex = shaIndex; } + return Z[i%5]; } diff --git a/sha.cpp b/sha.cpp index f64ff33d..9c691eb6 100644 --- a/sha.cpp +++ b/sha.cpp @@ -112,7 +112,7 @@ static void SHA1_SSE_SHA_Transform(word32 *state, const word32 *data) ABCD = _mm_loadu_si128((__m128i*) state); E0 = _mm_set_epi32(state[4], 0, 0, 0); ABCD = _mm_shuffle_epi32(ABCD, 0x1B); - MASK = _mm_set_epi8(3,2,1,0, 7,6,5,4, 11,10,9,8, 15,14,13,12); + MASK = _mm_set_epi8(0,1,2,3, 4,5,6,7, 8,9,10,11, 12,13,14,15); // Save current hash ABCD_SAVE = ABCD; @@ -498,6 +498,30 @@ void SHA1::Transform(word32 *state, const word32 *data) s_pfn(state, data); } +#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE +size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length) +{ + static const bool noReverse = HasSHA() || NativeByteOrderIs(this->GetByteOrder()); + const unsigned int blockSize = this->BlockSize(); + word32* dataBuf = this->DataBuf(); + do + { + if (noReverse) + this->HashEndianCorrectedBlock(input); + else + { + ByteReverse(dataBuf, input, this->BlockSize()); + this->HashEndianCorrectedBlock(dataBuf); + } + + input += blockSize/sizeof(word32); + length -= blockSize; + } + while (length >= blockSize); + return length; +} +#endif + // ************************************************************* void SHA224::InitState(HashWordType *state) @@ -1641,7 +1665,7 @@ CRYPTOPP_NAKED static void CRYPTOPP_FASTCALL SHA512_SSE2_Transform(word64 *state // first 16 rounds ASL(0) - AS2( movq mm0, [edx+eax*8]) + AS2( movq mm0, [edx+eax*8]) AS2( movq [esi+eax*8], mm0) AS2( movq [esi+eax*8+16*8], mm0) AS2( paddq mm0, [ebx+eax*8]) diff --git a/sha.h b/sha.h index 806317d4..7660909e 100644 --- a/sha.h +++ b/sha.h @@ -25,6 +25,9 @@ NAMESPACE_BEGIN(CryptoPP) class CRYPTOPP_DLL SHA1 : public IteratedHashWithStaticTransform { public: +#if CRYPTOPP_BOOL_SSE_SHA_INTRINSICS_AVAILABLE + size_t HashMultipleBlocks(const word32 *input, size_t length); +#endif static void CRYPTOPP_API InitState(HashWordType *state); static void CRYPTOPP_API Transform(word32 *digest, const word32 *data); CRYPTOPP_STATIC_CONSTEXPR const char* CRYPTOPP_API StaticAlgorithmName() {return "SHA-1";} From 77bea3f6303c53ca06cf6724420a69da6f6438aa Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Fri, 26 May 2017 09:13:18 +0200 Subject: [PATCH 09/49] hrtimer.cpp: fix Win32 DLL-Import build (#425) PerformanceCounterFrequency is used independently of CRYPTOPP_IMPORTS. --- hrtimer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hrtimer.cpp b/hrtimer.cpp index 1b89dcb2..f9b8a7cd 100644 --- a/hrtimer.cpp +++ b/hrtimer.cpp @@ -30,8 +30,6 @@ NAMESPACE_BEGIN(CryptoPP) -#ifndef CRYPTOPP_IMPORTS - #if defined(CRYPTOPP_WIN32_AVAILABLE) static TimerWord InitializePerformanceCounterFrequency() { @@ -48,6 +46,8 @@ inline TimerWord PerformanceCounterFrequency() } #endif +#ifndef CRYPTOPP_IMPORTS + double TimerBase::ConvertTo(TimerWord t, Unit unit) { static unsigned long unitsPerSecondTable[] = {1, 1000, 1000*1000, 1000*1000*1000}; From 306c88c8571596f47fb3479a200653c6d1b65e48 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 04:03:38 -0400 Subject: [PATCH 10/49] Updated test script --- TestScripts/cryptest.sh | 2 +- cryptest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index 26549f01..4801641e 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -5566,7 +5566,7 @@ if (( "$ECOUNT" == "0" )); then else echo "$ECOUNT errors detected. See $TEST_RESULTS for details" | tee -a "$TEST_RESULTS" if (( "$ECOUNT" < 16 )); then - "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector)' + "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector|Assertion|format-security)' fi fi diff --git a/cryptest.sh b/cryptest.sh index 26549f01..4801641e 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -5566,7 +5566,7 @@ if (( "$ECOUNT" == "0" )); then else echo "$ECOUNT errors detected. See $TEST_RESULTS for details" | tee -a "$TEST_RESULTS" if (( "$ECOUNT" < 16 )); then - "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector)' + "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector|Assertion|format-security)' fi fi From aeb7f9bac97cbc5c32de86dca5f9b50cec546e55 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 04:12:21 -0400 Subject: [PATCH 11/49] Updated test script --- TestScripts/cryptest.sh | 2 +- cryptest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index 26549f01..4801641e 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -5566,7 +5566,7 @@ if (( "$ECOUNT" == "0" )); then else echo "$ECOUNT errors detected. See $TEST_RESULTS for details" | tee -a "$TEST_RESULTS" if (( "$ECOUNT" < 16 )); then - "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector)' + "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector|Assertion|format-security)' fi fi diff --git a/cryptest.sh b/cryptest.sh index 26549f01..4801641e 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -5566,7 +5566,7 @@ if (( "$ECOUNT" == "0" )); then else echo "$ECOUNT errors detected. See $TEST_RESULTS for details" | tee -a "$TEST_RESULTS" if (( "$ECOUNT" < 16 )); then - "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector)' + "$EGREP" -n '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' "$TEST_RESULTS" | "$EGREP" -v '( 0 errors|suppressed errors|error detector|Assertion|format-security)' fi fi From 167d4ae1a596592d8e051a438ee02854172d3c37 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 04:27:45 -0400 Subject: [PATCH 12/49] Updated test script --- TestScripts/cryptest.sh | 2 +- cryptest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index 4801641e..ec3f412b 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -1752,7 +1752,7 @@ if [[ ("$IS_FEDORA" -ne "0") ]]; then # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/x86_64/build.log if [[ ("$IS_X86" -ne "0") ]]; then MARCH_OPT=(-m32 -march=i686) - else + if [[ ("$IS_X64" -ne "0") ]]; then MARCH_OPT=(-m64 -mtune=generic) fi diff --git a/cryptest.sh b/cryptest.sh index 4801641e..ec3f412b 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -1752,7 +1752,7 @@ if [[ ("$IS_FEDORA" -ne "0") ]]; then # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/x86_64/build.log if [[ ("$IS_X86" -ne "0") ]]; then MARCH_OPT=(-m32 -march=i686) - else + if [[ ("$IS_X64" -ne "0") ]]; then MARCH_OPT=(-m64 -mtune=generic) fi From 6055aac84f2f8ec3104912597438f5d913470843 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 04:36:38 -0400 Subject: [PATCH 13/49] Updated test script --- TestScripts/cryptest.sh | 2 +- cryptest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index ec3f412b..35abe984 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -1752,7 +1752,7 @@ if [[ ("$IS_FEDORA" -ne "0") ]]; then # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/x86_64/build.log if [[ ("$IS_X86" -ne "0") ]]; then MARCH_OPT=(-m32 -march=i686) - if [[ ("$IS_X64" -ne "0") ]]; then + elif [[ ("$IS_X64" -ne "0") ]]; then MARCH_OPT=(-m64 -mtune=generic) fi diff --git a/cryptest.sh b/cryptest.sh index ec3f412b..35abe984 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -1752,7 +1752,7 @@ if [[ ("$IS_FEDORA" -ne "0") ]]; then # https://kojipkgs.fedoraproject.org//packages/cryptopp/5.6.3/8.fc27/data/logs/x86_64/build.log if [[ ("$IS_X86" -ne "0") ]]; then MARCH_OPT=(-m32 -march=i686) - if [[ ("$IS_X64" -ne "0") ]]; then + elif [[ ("$IS_X64" -ne "0") ]]; then MARCH_OPT=(-m64 -mtune=generic) fi From 554ce2c577ca7d7c2e86c7fcebcba80f3263b84c Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 05:28:51 -0400 Subject: [PATCH 14/49] Updated test script --- TestScripts/cryptest.sh | 8 ++++---- cryptest.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index 35abe984..a1a0dfd3 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -823,8 +823,8 @@ CPU_COUNT=1 MEM_SIZE=512 if [[ (-e "/proc/cpuinfo") && (-e "/proc/meminfo") ]]; then - CPU_COUNT=$(cat /proc/cpuinfo | "$GREP" -c '^processor') - MEM_SIZE=$(cat /proc/meminfo | "$GREP" "MemTotal" | "$AWK" '{print $2}') + CPU_COUNT=$(cat /proc/cpuinfo 2>&1 | "$GREP" -c '^processor') + MEM_SIZE=$(cat /proc/meminfo 2>&1 | "$GREP" "MemTotal" | "$AWK" '{print $2}') MEM_SIZE=$(($MEM_SIZE/1024)) elif [[ "$IS_DARWIN" -ne "0" ]]; then CPU_COUNT=$(sysctl -a 2>&1 | "$GREP" 'hw.availcpu' | "$AWK" '{print $3; exit}') @@ -841,7 +841,7 @@ if [[ (-e "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq") ]]; then CPU_FREQ=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq) CPU_FREQ=$("$AWK" "BEGIN {print $CPU_FREQ/1024/1024}") elif [[ (-e "/proc/cpuinfo") ]]; then - CPU_FREQ=$(cat /proc/cpuinfo | "$GREP" 'MHz' | "$AWK" '{print $4; exit}') + CPU_FREQ=$(cat /proc/cpuinfo 2>&1 | "$GREP" 'MHz' | "$AWK" '{print $4; exit}') if [[ -z "$CPU_FREQ" ]]; then CPU_FREQ=512; fi CPU_FREQ=$("$AWK" "BEGIN {print $CPU_FREQ/1024}") elif [[ "$IS_DARWIN" -ne "0" ]]; then @@ -857,7 +857,7 @@ fi HAVE_SWAP=1 if [[ "$IS_LINUX" -ne "0" ]]; then if [[ (-e "/proc/meminfo") ]]; then - SWAP_SIZE=$(cat /proc/meminfo | "$GREP" "SwapTotal" | "$AWK" '{print $2}') + SWAP_SIZE=$(cat /proc/meminfo 2>&1 | "$GREP" "SwapTotal" | "$AWK" '{print $2}') if [[ "$SWAP_SIZE" -eq "0" ]]; then HAVE_SWAP=0 fi diff --git a/cryptest.sh b/cryptest.sh index 35abe984..a1a0dfd3 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -823,8 +823,8 @@ CPU_COUNT=1 MEM_SIZE=512 if [[ (-e "/proc/cpuinfo") && (-e "/proc/meminfo") ]]; then - CPU_COUNT=$(cat /proc/cpuinfo | "$GREP" -c '^processor') - MEM_SIZE=$(cat /proc/meminfo | "$GREP" "MemTotal" | "$AWK" '{print $2}') + CPU_COUNT=$(cat /proc/cpuinfo 2>&1 | "$GREP" -c '^processor') + MEM_SIZE=$(cat /proc/meminfo 2>&1 | "$GREP" "MemTotal" | "$AWK" '{print $2}') MEM_SIZE=$(($MEM_SIZE/1024)) elif [[ "$IS_DARWIN" -ne "0" ]]; then CPU_COUNT=$(sysctl -a 2>&1 | "$GREP" 'hw.availcpu' | "$AWK" '{print $3; exit}') @@ -841,7 +841,7 @@ if [[ (-e "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq") ]]; then CPU_FREQ=$(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq) CPU_FREQ=$("$AWK" "BEGIN {print $CPU_FREQ/1024/1024}") elif [[ (-e "/proc/cpuinfo") ]]; then - CPU_FREQ=$(cat /proc/cpuinfo | "$GREP" 'MHz' | "$AWK" '{print $4; exit}') + CPU_FREQ=$(cat /proc/cpuinfo 2>&1 | "$GREP" 'MHz' | "$AWK" '{print $4; exit}') if [[ -z "$CPU_FREQ" ]]; then CPU_FREQ=512; fi CPU_FREQ=$("$AWK" "BEGIN {print $CPU_FREQ/1024}") elif [[ "$IS_DARWIN" -ne "0" ]]; then @@ -857,7 +857,7 @@ fi HAVE_SWAP=1 if [[ "$IS_LINUX" -ne "0" ]]; then if [[ (-e "/proc/meminfo") ]]; then - SWAP_SIZE=$(cat /proc/meminfo | "$GREP" "SwapTotal" | "$AWK" '{print $2}') + SWAP_SIZE=$(cat /proc/meminfo 2>&1 | "$GREP" "SwapTotal" | "$AWK" '{print $2}') if [[ "$SWAP_SIZE" -eq "0" ]]; then HAVE_SWAP=0 fi From b770b21dc4fee01bde807f4c19e859a680dd9156 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 06:30:46 -0400 Subject: [PATCH 15/49] Fix Travis hang --- .travis.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9efb17f6..29fab278 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,7 @@ dist: trusty sudo: false # OS X only supports one image. Us the latest. -osx_image: - - xcode8.2 -# - xcode7.3 -# - xcode6.4 +osx_image: xcode8.2 git: depth: 3 From 3bb801101f7f6eaea51cbb6a7ba0ae5349885b99 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 09:29:05 -0400 Subject: [PATCH 16/49] Updated test script --- TestScripts/cryptest.sh | 2 +- cryptest.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index a1a0dfd3..e2a058d6 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -5560,7 +5560,7 @@ echo | tee -a "$TEST_RESULTS" # "Error" is from the GNU assembler # "error" is from the sanitizers # "Illegal", "Conditional", "0 errors" and "suppressed errors" are from Valgrind. -ECOUNT=$("$EGREP" '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' $TEST_RESULTS | "$EGREP" -v '( 0 errors|suppressed errors|error detector)' | wc -l | "$AWK" '{print $1}') +ECOUNT=$("$EGREP" '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' $TEST_RESULTS | "$EGREP" -v '( 0 errors|suppressed errors|error detector|format-security)' | wc -l | "$AWK" '{print $1}') if (( "$ECOUNT" == "0" )); then echo "No failures detected" | tee -a "$TEST_RESULTS" else diff --git a/cryptest.sh b/cryptest.sh index a1a0dfd3..e2a058d6 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -5560,7 +5560,7 @@ echo | tee -a "$TEST_RESULTS" # "Error" is from the GNU assembler # "error" is from the sanitizers # "Illegal", "Conditional", "0 errors" and "suppressed errors" are from Valgrind. -ECOUNT=$("$EGREP" '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' $TEST_RESULTS | "$EGREP" -v '( 0 errors|suppressed errors|error detector)' | wc -l | "$AWK" '{print $1}') +ECOUNT=$("$EGREP" '(Error|ERROR|error|FAILED|Illegal|Conditional|CryptoPP::Exception)' $TEST_RESULTS | "$EGREP" -v '( 0 errors|suppressed errors|error detector|format-security)' | wc -l | "$AWK" '{print $1}') if (( "$ECOUNT" == "0" )); then echo "No failures detected" | tee -a "$TEST_RESULTS" else From 4f5dd74286b26bd0b3ba5f20ad7b2ac2d3aa0a32 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 09:41:15 -0400 Subject: [PATCH 17/49] Update Travis config file --- .travis.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 29fab278..ab8cab0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ os: dist: trusty sudo: false -# OS X only supports one image. Us the latest. +# OS X only supports one image. Use the latest. osx_image: xcode8.2 git: @@ -36,7 +36,6 @@ env: # The sanitizer builds under Clang run the tests very # slowly and cause CI timeouts. - - compiler: clang env: BUILD_MODE="asan" - compiler: clang @@ -44,10 +43,22 @@ env: - compiler: clang env: BUILD_MODE="valgrind" +script: + - make clean &>/dev/null && make + - ./cryptest.exe v && ./cryptest.exe tv all + # whitelist branches to avoid testing feature branches twice branches: only: - master +addons: + sonarqube: true + + coverity_scan: + project: + name: "cryptopp" + build_command: "make -j 2" + #notifications: # email: jdoe@example.com From 84e6961457eea48c7f79a588cd1c1a61bf7d5cbf Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 10:08:44 -0400 Subject: [PATCH 18/49] Updated makefile trim and convert rules Whitespace check-in --- .appveyor.yml | 4 +- .travis.yml | 128 +++++++++++++++---------------- GNUmakefile | 12 +-- TestScripts/coverity-linux.txt | 64 ++++++++-------- TestScripts/coverity-macosx.txt | 72 ++++++++--------- TestScripts/coverity-windows.txt | 60 +++++++-------- 6 files changed, 170 insertions(+), 170 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 67a71b8a..2f8d0246 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -34,9 +34,9 @@ test_script: - cmd: >- msbuild /t:CopyCryptestToRoot cryptest.vcxproj - + cryptest.exe v - + cryptest.exe tv all # Right now, we have a few failures that we don't know how to workaround. diff --git a/.travis.yml b/.travis.yml index ab8cab0d..fd86436c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,64 +1,64 @@ -language: cpp - -os: - - linux - - osx - -dist: trusty -sudo: false - -# OS X only supports one image. Use the latest. -osx_image: xcode8.2 - -git: - depth: 3 - -compiler: - - clang - - gcc - -env: - global: - - BUILD_JOBS=2 - - matrix: - - BUILD_MODE="shared" - - BUILD_MODE="static" - - BUILD_MODE="no-asm" - - BUILD_MODE="asan" - - BUILD_MODE="ubsan" - - BUILD_MODE="valgrind" - - exclude: - # Skip GCC on OS X entirely - - os: osx - compiler: gcc - - # The sanitizer builds under Clang run the tests very - # slowly and cause CI timeouts. - - compiler: clang - env: BUILD_MODE="asan" - - compiler: clang - env: BUILD_MODE="ubsan" - - compiler: clang - env: BUILD_MODE="valgrind" - -script: - - make clean &>/dev/null && make - - ./cryptest.exe v && ./cryptest.exe tv all - -# whitelist branches to avoid testing feature branches twice -branches: - only: - - master - -addons: - sonarqube: true - - coverity_scan: - project: - name: "cryptopp" - build_command: "make -j 2" - -#notifications: -# email: jdoe@example.com +language: cpp + +os: + - linux + - osx + +dist: trusty +sudo: false + +# OS X only supports one image. Use the latest. +osx_image: xcode8.2 + +git: + depth: 3 + +compiler: + - clang + - gcc + +env: + global: + - BUILD_JOBS=2 + + matrix: + - BUILD_MODE="shared" + - BUILD_MODE="static" + - BUILD_MODE="no-asm" + - BUILD_MODE="asan" + - BUILD_MODE="ubsan" + - BUILD_MODE="valgrind" + + exclude: + # Skip GCC on OS X entirely + - os: osx + compiler: gcc + + # The sanitizer builds under Clang run the tests very + # slowly and cause CI timeouts. + - compiler: clang + env: BUILD_MODE="asan" + - compiler: clang + env: BUILD_MODE="ubsan" + - compiler: clang + env: BUILD_MODE="valgrind" + +script: + - make clean &>/dev/null && make + - ./cryptest.exe v && ./cryptest.exe tv all + +# whitelist branches to avoid testing feature branches twice +branches: + only: + - master + +addons: + sonarqube: true + + coverity_scan: + project: + name: "cryptopp" + build_command: "make -j 2" + +#notifications: +# email: jdoe@example.com diff --git a/GNUmakefile b/GNUmakefile index 91633f7f..6acf84fe 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -725,22 +725,22 @@ endif .PHONY: trim trim: ifneq ($(IS_DARWIN),0) - sed -i '' -e's/[[:space:]]*$$//' *.sh *.h *.cpp *.asm *.s *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross - sed -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestScripts/*.sh + sed -i '' -e's/[[:space:]]*$$//' *.sh .*.yml *.h *.cpp *.asm *.s *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross + sed -i '' -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestScripts/*.* make convert else - sed -i -e's/[[:space:]]*$$//' *.sh *.h *.cpp *.asm *.s *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross - sed -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestScripts/*.sh + sed -i -e's/[[:space:]]*$$//' *.sh .*.yml *.h *.cpp *.asm *.s *.sln *.vcxproj *.filters GNUmakefile GNUmakefile-cross + sed -i -e's/[[:space:]]*$$//' TestData/*.dat TestVectors/*.txt TestScripts/*.* make convert endif .PHONY: convert convert: @-$(CHMOD) 0700 TestVectors/ TestData/ TestScripts/ - @-$(CHMOD) 0600 $(TEXT_FILES) *.asm *.s *.zip *.cmake TestVectors/*.txt TestData/*.dat + @-$(CHMOD) 0600 $(TEXT_FILES) .*.yml *.asm *.s *.zip *.cmake TestVectors/*.txt TestData/*.dat TestScripts/*.* @-$(CHMOD) 0700 $(EXEC_FILES) *.sh *.cmd TestScripts/*.sh TestScripts/*.pl TestScripts/*.cmd @-$(CHMOD) 0700 *.cmd *.sh GNUmakefile GNUmakefile-cross TestScripts/*.sh TestScripts/*.pl - -unix2dos --keepdate --quiet $(TEXT_FILES) *.asm *.cmd *.cmake TestScripts/*.pl TestScripts/*.cmd + -unix2dos --keepdate --quiet $(TEXT_FILES) .*.yml *.asm *.cmd *.cmake TestScripts/*.* -dos2unix --keepdate --quiet GNUmakefile GNUmakefile-cross *.s *.sh TestScripts/*.sh ifneq ($(IS_DARWIN),0) @-xattr -c * diff --git a/TestScripts/coverity-linux.txt b/TestScripts/coverity-linux.txt index b6805af6..3eedcb6c 100644 --- a/TestScripts/coverity-linux.txt +++ b/TestScripts/coverity-linux.txt @@ -1,32 +1,32 @@ -# coverity-linux.txt - Scan build submission instructions for Unix and Linux. -# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal. -# Copyright assigned to Crypto++ project. -# -# The following are copy/paste instructions for invoking cov-build, building the library and submitting the artifacts for a scan. -# -# For more information see http://cryptopp.com/wiki/Coverity_Scan. - -################################################################## - -reset - -make distclean &>/dev/null - -# Usually we test with these flags -# CXXFLAGS="-DNDEBUG -g3 -O2" - -# Testing for Issue 302 (http://github.com/weidai11/cryptopp/issues/302) -CXXFLAGS="-DNDEBUG -g2 -O3 -march=i686 -msse -msse2 -msse3 -mssse3 -mno-aes" cov-build --dir cov-int make -j 2 - -tar czvf cryptopp.tgz cov-int - -CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX -COVERITY_SCAN_NAME="Rijndael-AliasedTable-SSE2-Linux-i686" - -curl - --form token="$CRYPTOPP_COVERITY_TOKEN" \ - --form email=webmaster@cryptopp.com \ - --form file=@cryptopp.tgz \ - --form version="$COVERITY_SCAN_NAME" \ - --form description="$COVERITY_SCAN_NAME" \ - https://scan.coverity.com/builds?project=Cryptopp +# coverity-linux.txt - Scan build submission instructions for Unix and Linux. +# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal. +# Copyright assigned to Crypto++ project. +# +# The following are copy/paste instructions for invoking cov-build, building the library and submitting the artifacts for a scan. +# +# For more information see http://cryptopp.com/wiki/Coverity_Scan. + +################################################################## + +reset + +make distclean &>/dev/null + +# Usually we test with these flags +# CXXFLAGS="-DNDEBUG -g3 -O2" + +# Testing for Issue 302 (http://github.com/weidai11/cryptopp/issues/302) +CXXFLAGS="-DNDEBUG -g2 -O3 -march=i686 -msse -msse2 -msse3 -mssse3 -mno-aes" cov-build --dir cov-int make -j 2 + +tar czvf cryptopp.tgz cov-int + +CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX +COVERITY_SCAN_NAME="Rijndael-AliasedTable-SSE2-Linux-i686" + +curl + --form token="$CRYPTOPP_COVERITY_TOKEN" \ + --form email=webmaster@cryptopp.com \ + --form file=@cryptopp.tgz \ + --form version="$COVERITY_SCAN_NAME" \ + --form description="$COVERITY_SCAN_NAME" \ + https://scan.coverity.com/builds?project=Cryptopp diff --git a/TestScripts/coverity-macosx.txt b/TestScripts/coverity-macosx.txt index fe778240..d5df3f75 100644 --- a/TestScripts/coverity-macosx.txt +++ b/TestScripts/coverity-macosx.txt @@ -1,36 +1,36 @@ -# coverity-linux.txt - Scan build submission instructions for Unix and Linux. -# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal. -# Copyright assigned to Crypto++ project. -# -# The following are copy/paste instructions for invoking cov-build, building the library and submitting the artifacts for a scan. -# -# For more information see http://cryptopp.com/wiki/Coverity_Scan. - -################################################################## - -reset - -make distclean &>/dev/null - -# Usually we test with these flags -CXXFLAGS="-DNDEBUG -g3 -O2" cov-build --dir cov-int make -j 2 - -# Sometimes we need these flags (add COVERITY_UNSUPPORTED) -# COVERITY_UNSUPPORTED=1 CXXFLAGS="-DNDEBUG -g3 -O2" cov-build --dir cov-int make -j 2 - -# Sometimes we need these flags (alternate compile, C++11) -# CXX=/opt/local/bin/clang++-mp-3.7 COVERITY_UNSUPPORTED=1 CXXFLAGS="-DNDEBUG -g3 -O2 -std=c++11" cov-build --dir cov-int make -j 2 - - -tar czvf cryptopp.tgz cov-int - -CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX -COVERITY_SCAN_NAME="Cryptopp-MacOSX-x86_64" - -curl - --form token="$CRYPTOPP_COVERITY_TOKEN" \ - --form email=webmaster@cryptopp.com \ - --form file=@cryptopp.tgz \ - --form version="$COVERITY_SCAN_NAME" \ - --form description="$COVERITY_SCAN_NAME" \ - https://scan.coverity.com/builds?project=Cryptopp +# coverity-linux.txt - Scan build submission instructions for Unix and Linux. +# Written and placed in public domain by Jeffrey Walton and Uri Blumenthal. +# Copyright assigned to Crypto++ project. +# +# The following are copy/paste instructions for invoking cov-build, building the library and submitting the artifacts for a scan. +# +# For more information see http://cryptopp.com/wiki/Coverity_Scan. + +################################################################## + +reset + +make distclean &>/dev/null + +# Usually we test with these flags +CXXFLAGS="-DNDEBUG -g3 -O2" cov-build --dir cov-int make -j 2 + +# Sometimes we need these flags (add COVERITY_UNSUPPORTED) +# COVERITY_UNSUPPORTED=1 CXXFLAGS="-DNDEBUG -g3 -O2" cov-build --dir cov-int make -j 2 + +# Sometimes we need these flags (alternate compile, C++11) +# CXX=/opt/local/bin/clang++-mp-3.7 COVERITY_UNSUPPORTED=1 CXXFLAGS="-DNDEBUG -g3 -O2 -std=c++11" cov-build --dir cov-int make -j 2 + + +tar czvf cryptopp.tgz cov-int + +CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX +COVERITY_SCAN_NAME="Cryptopp-MacOSX-x86_64" + +curl + --form token="$CRYPTOPP_COVERITY_TOKEN" \ + --form email=webmaster@cryptopp.com \ + --form file=@cryptopp.tgz \ + --form version="$COVERITY_SCAN_NAME" \ + --form description="$COVERITY_SCAN_NAME" \ + https://scan.coverity.com/builds?project=Cryptopp diff --git a/TestScripts/coverity-windows.txt b/TestScripts/coverity-windows.txt index b289920d..c8f2f381 100644 --- a/TestScripts/coverity-windows.txt +++ b/TestScripts/coverity-windows.txt @@ -1,30 +1,30 @@ -REM coverity-windows.txt - Scan build submission instructions for Windows using cryptest.nmake. -REM Written and placed in public domain by Jeffrey Walton and Uri Blumenthal. -REM Copyright assigned to Crypto++ project. -REM -REM The following are copy/paste instructions for invoking cov-build, building the library and -REM submitting the artifacts for a scan. Also see http://cryptopp.com/wiki/Coverity_Scan. - -REM ################################################################ - -cls - -del /f cryptopp.zip -rmdir /q /s cov-int -nmake /f cryptest.nmake clean - -REM Uncomment CXXFLAGS in makefile. Pay attention to X86, X64 or ARM -cov-build.exe --dir cov-int nmake /f cryptest.nmake - -7z.exe a -r -tzip -mx=9 cryptopp.zip cov-int - -set CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX -set COVERITY_SCAN_NAME=Rijndael-AliasedTable-SSE2-Windows-X64 - -curl.exe ^ - --form token="%CRYPTOPP_COVERITY_TOKEN%" ^ - --form email=webmaster@cryptopp.com ^ - --form file=@cryptopp.zip ^ - --form version="%COVERITY_SCAN_NAME%" ^ - --form description="%COVERITY_SCAN_NAME%" ^ - https://scan.coverity.com/builds?project=Cryptopp +REM coverity-windows.txt - Scan build submission instructions for Windows using cryptest.nmake. +REM Written and placed in public domain by Jeffrey Walton and Uri Blumenthal. +REM Copyright assigned to Crypto++ project. +REM +REM The following are copy/paste instructions for invoking cov-build, building the library and +REM submitting the artifacts for a scan. Also see http://cryptopp.com/wiki/Coverity_Scan. + +REM ################################################################ + +cls + +del /f cryptopp.zip +rmdir /q /s cov-int +nmake /f cryptest.nmake clean + +REM Uncomment CXXFLAGS in makefile. Pay attention to X86, X64 or ARM +cov-build.exe --dir cov-int nmake /f cryptest.nmake + +7z.exe a -r -tzip -mx=9 cryptopp.zip cov-int + +set CRYPTOPP_COVERITY_TOKEN=XXXXXXXXXXXXXXXX +set COVERITY_SCAN_NAME=Rijndael-AliasedTable-SSE2-Windows-X64 + +curl.exe ^ + --form token="%CRYPTOPP_COVERITY_TOKEN%" ^ + --form email=webmaster@cryptopp.com ^ + --form file=@cryptopp.zip ^ + --form version="%COVERITY_SCAN_NAME%" ^ + --form description="%COVERITY_SCAN_NAME%" ^ + https://scan.coverity.com/builds?project=Cryptopp From 0af3a2525c5ef80cf9e135f4148b2d3619f1a68d Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 22:20:38 -0400 Subject: [PATCH 19/49] Update makefile rules and recipes --- GNUmakefile-cross | 75 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/GNUmakefile-cross b/GNUmakefile-cross index 31b47559..1ce04681 100755 --- a/GNUmakefile-cross +++ b/GNUmakefile-cross @@ -1,8 +1,5 @@ -CXXFLAGS ?= -DNDEBUG -g2 -Os -fPIC -pipe - -# The following options reduce code size, but breaks link or makes link very slow on some systems -# CXXFLAGS += -ffunction-sections -fdata-sections -# LDFLAGS += -Wl,--gc-sections +# Default CXXFLAGS if none were provided +CXXFLAGS ?= -DNDEBUG -g2 -O3 -fPIC -pipe AR ?= ar ARFLAGS ?= cr @@ -91,6 +88,70 @@ ifeq ($(IS_ARM_EMBEDDED),1) CXXFLAGS += $(ARM_EMBEDDED_FLAGS) --sysroot=$(ARM_EMBEDDED_SYSROOT) endif +# No ASM for Travis testing +ifeq ($(findstring no-asm,$(MAKECMDGOALS)),no-asm) + ifeq ($(findstring -DCRYPTOPP_DISABLE_ASM,$(CXXFLAGS)),) + CXXFLAGS += -DCRYPTOPP_DISABLE_ASM + endif # CXXFLAGS +endif # No ASM + +# Undefined Behavior Sanitizer (UBsan) testing. Issue 'make ubsan'. +ifeq ($(findstring ubsan,$(MAKECMDGOALS)),ubsan) + ifeq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),) + CXXFLAGS += -fsanitize=undefined + endif # CXXFLAGS + ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),) + CXXFLAGS += -DCRYPTOPP_COVERAGE + endif # CXXFLAGS +endif # UBsan + +# Address Sanitizer (Asan) testing. Issue 'make asan'. +ifeq ($(findstring asan,$(MAKECMDGOALS)),asan) + ifeq ($(findstring -fsanitize=address,$(CXXFLAGS)),) + CXXFLAGS += -fsanitize=address + endif # CXXFLAGS + ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),) + CXXFLAGS += -DCRYPTOPP_COVERAGE + endif # CXXFLAGS + ifeq ($(findstring -fno-omit-frame-pointer,$(CXXFLAGS)),) + CXXFLAGS += -fno-omit-frame-pointer + endif # CXXFLAGS +endif # Asan + +# LD gold linker testing. Triggered by 'LD=ld.gold'. +ifeq ($(findstring ld.gold,$(LD)),ld.gold) + ifeq ($(findstring -fuse-ld=gold,$(CXXFLAGS)),) + ELF_FORMAT := $(shell file `which ld.gold` 2>&1 | cut -d":" -f 2 | $(EGREP) -i -c "elf") + ifneq ($(ELF_FORMAT),0) + LDFLAGS += -fuse-ld=gold + endif # ELF/ELF64 + endif # CXXFLAGS +endif # Gold + +# Valgrind testing. Issue 'make valgrind'. +ifneq ($(filter valgrind,$(MAKECMDGOALS)),) + # Tune flags; see http://valgrind.org/docs/manual/quick-start.html + CXXFLAGS := $(CXXFLAGS:-g%=-g3) + CXXFLAGS := $(CXXFLAGS:-O%=-O1) + CXXFLAGS := $(CXXFLAGS:-xO%=-xO1) + ifeq ($(findstring -DCRYPTOPP_VALGRIND,$(CXXFLAGS)),) + CXXFLAGS += -DCRYPTOPP_VALGRIND + endif # -DCRYPTOPP_VALGRIND +endif # Valgrind + +# Debug testing on GNU systems. Triggered by -DDEBUG. +# Newlib test due to http://sourceware.org/bugzilla/show_bug.cgi?id=20268 +ifneq ($(filter -DDEBUG -DDEBUG=1,$(CXXFLAGS)),) + USING_GLIBCXX := $(shell $(CXX) -x c++ $(CXXFLAGS) -E adhoc.cpp.proto 2>&1 | $(EGREP) -i -c "__GLIBCXX__") + ifneq ($(USING_GLIBCXX),0) + ifeq ($(HAS_NEWLIB),0) + ifeq ($(findstring -D_GLIBCXX_DEBUG,$(CXXFLAGS)),) + CXXFLAGS += -D_GLIBCXX_DEBUG + endif # CXXFLAGS + endif # HAS_NEWLIB + endif # USING_GLIBCXX +endif # GNU Debug build + # Dead code stripping. Issue 'make lean'. ifeq ($(findstring lean,$(MAKECMDGOALS)),lean) ifeq ($(findstring -ffunction-sections,$(CXXFLAGS)),) @@ -99,7 +160,7 @@ ifeq ($(findstring lean,$(MAKECMDGOALS)),lean) ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),) CXXFLAGS += -fdata-sections endif # CXXFLAGS - ifeq ($(IS_IOS),1) + ifneq ($(IS_DARWIN),0) ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),) LDFLAGS += -Wl,-dead_strip endif # CXXFLAGS @@ -111,7 +172,7 @@ ifeq ($(findstring lean,$(MAKECMDGOALS)),lean) endif # Dead code stripping # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems. -SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(wildcard *.cpp)) +SRCS := cryptlib.cpp cpu.cpp integer.cpp $(filter-out cryptlib.cpp cpu.cpp integer.cpp pch.cpp simple.cpp winpipes.cpp cryptlib_bds.cpp,$(sort $(wildcard *.cpp))) # List cryptlib.cpp first, then cpu.cpp, then integer.cpp to tame C++ static initialization problems. OBJS := $(SRCS:.cpp=.o) From ea12b5af0bd9c808a4a14016c89bd21a52fad13c Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 26 May 2017 22:23:35 -0400 Subject: [PATCH 20/49] Use IS_IOS instead of IS_DARWIN --- GNUmakefile-cross | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile-cross b/GNUmakefile-cross index 1ce04681..0a3717ae 100755 --- a/GNUmakefile-cross +++ b/GNUmakefile-cross @@ -160,7 +160,7 @@ ifeq ($(findstring lean,$(MAKECMDGOALS)),lean) ifeq ($(findstring -fdata-sections,$(CXXFLAGS)),) CXXFLAGS += -fdata-sections endif # CXXFLAGS - ifneq ($(IS_DARWIN),0) + ifneq ($(IS_IOS),0) ifeq ($(findstring -Wl,-dead_strip,$(LDFLAGS)),) LDFLAGS += -Wl,-dead_strip endif # CXXFLAGS From b02ab0a0ba3725b8b2c68ca0a973a2a9b0b1c7c7 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 00:41:58 -0400 Subject: [PATCH 21/49] Tune Travis configuration Now that the jobs are running we can start fixing the little issues --- .travis.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd86436c..08e94ef2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,30 +22,24 @@ env: - BUILD_JOBS=2 matrix: - - BUILD_MODE="shared" - - BUILD_MODE="static" + - BUILD_MODE="all" - BUILD_MODE="no-asm" - BUILD_MODE="asan" - BUILD_MODE="ubsan" - - BUILD_MODE="valgrind" exclude: # Skip GCC on OS X entirely - os: osx compiler: gcc - # The sanitizer builds under Clang run the tests very - # slowly and cause CI timeouts. + # The sanitizer builds under Clang are very slow. - compiler: clang env: BUILD_MODE="asan" - compiler: clang env: BUILD_MODE="ubsan" - - compiler: clang - env: BUILD_MODE="valgrind" script: - - make clean &>/dev/null && make - - ./cryptest.exe v && ./cryptest.exe tv all + - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all # whitelist branches to avoid testing feature branches twice branches: From 37cd5bcf7bbe8d889225baf8e0c4d016ab2a9798 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 01:19:48 -0400 Subject: [PATCH 22/49] Remove VS2010 and VS2012 configurations Apparently Appveyor does not support them. Also see https://stackoverflow.com/q/43441273/608639 --- .appveyor.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2f8d0246..ed8bd77f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -20,8 +20,6 @@ image: - Visual Studio 2017 - Visual Studio 2015 - Visual Studio 2013 -- Visual Studio 2012 -- Visual Studio 2010 build: From 3c504b3401731a6f500f6e4f7d274f6a32d38065 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 03:08:07 -0400 Subject: [PATCH 23/49] Attempt to add Code Coverage report This should be interesting... --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 08e94ef2..a5d7b5a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,13 +26,14 @@ env: - BUILD_MODE="no-asm" - BUILD_MODE="asan" - BUILD_MODE="ubsan" + - BUILD_MODE="coverage" exclude: # Skip GCC on OS X entirely - os: osx compiler: gcc - # The sanitizer builds under Clang are very slow. + # The sanitizer builds under Clang run slowly - compiler: clang env: BUILD_MODE="asan" - compiler: clang @@ -41,6 +42,9 @@ env: script: - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all +after_success: + - if [[ "$BUILD_MODE" = "coverage" ]]; then bash <(curl -s https://codecov.io/bash) fi; + # whitelist branches to avoid testing feature branches twice branches: only: From 345b4e49e296c277dc847dd28366e64efb048f47 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 03:42:50 -0400 Subject: [PATCH 24/49] Attempt to add Code Coverage report (Take 2) This should be interesting... --- .travis.yml | 4 ++-- GNUmakefile | 21 +++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index a5d7b5a4..6d6910ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ env: - BUILD_MODE="no-asm" - BUILD_MODE="asan" - BUILD_MODE="ubsan" - - BUILD_MODE="coverage" + - BUILD_MODE="codecov" exclude: # Skip GCC on OS X entirely @@ -43,7 +43,7 @@ script: - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all after_success: - - if [[ "$BUILD_MODE" = "coverage" ]]; then bash <(curl -s https://codecov.io/bash) fi; + - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then bash <(curl -s https://codecov.io/bash) fi; # whitelist branches to avoid testing feature branches twice branches: diff --git a/GNUmakefile b/GNUmakefile index 6acf84fe..56124362 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -404,11 +404,21 @@ endif # ELF/ELF64 endif # CXXFLAGS endif # Gold -# GCC code coverage. Issue 'make coverage'. +# lcov code coverage. Issue 'make coverage'. ifneq ($(filter coverage,$(MAKECMDGOALS)),) ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),) CXXFLAGS += -DCRYPTOPP_COVERAGE +endif # CRYPTOPP_COVERAGE +ifeq ($(findstring -coverage,$(CXXFLAGS)),) +CXXFLAGS += -coverage endif # -coverage +endif # GCC code coverage + +# gcov code coverage for Travis. Issue 'make codecov'. +ifneq ($(filter codecov,$(MAKECMDGOALS)),) +ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),) +CXXFLAGS += -DCRYPTOPP_COVERAGE +endif # CRYPTOPP_COVERAGE ifeq ($(findstring -coverage,$(CXXFLAGS)),) CXXFLAGS += -coverage endif # -coverage @@ -557,7 +567,14 @@ coverage: libcryptopp.a cryptest.exe lcov --remove cryptest.info "adhoc.cpp" "wait.*" "network.*" "socketft.*" "fips140.*" "*test.*" "bench*.cpp" "validat*.*" "/usr/*" -o cryptest.info genhtml -o ./TestCoverage/ -t "cryptest.exe test coverage" --num-spaces 4 cryptest.info -# SHould use CXXFLAGS="-g3 -O1" +# Travis CI and CodeCov rule +.PHONY: codecov +coverage: libcryptopp.a cryptest.exe + @-$(RM) -r ./TestCoverage/ + ./cryptest.exe v + ./cryptest.exe tv all + +# Should use CXXFLAGS="-g3 -O1" .PHONY: valgrind valgrind: libcryptopp.a cryptest.exe valgrind ./cryptest.exe v From 40395c0150f0a988546a71370791d12a85736f8f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 03:47:50 -0400 Subject: [PATCH 25/49] Attempt to add Code Coverage report (Take 3) This should be interesting... --- GNUmakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 56124362..01342db4 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -569,10 +569,11 @@ coverage: libcryptopp.a cryptest.exe # Travis CI and CodeCov rule .PHONY: codecov -coverage: libcryptopp.a cryptest.exe +codecov: libcryptopp.a cryptest.exe @-$(RM) -r ./TestCoverage/ ./cryptest.exe v ./cryptest.exe tv all + gcov $(SRCS) # Should use CXXFLAGS="-g3 -O1" .PHONY: valgrind From b5240463f1c39786c8b1c62989efc65662751f32 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 04:21:51 -0400 Subject: [PATCH 26/49] Attempt to add Code Coverage report (Take 4) This should be interesting... --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6d6910ad..cdb06f33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,11 +33,13 @@ env: - os: osx compiler: gcc - # The sanitizer builds under Clang run slowly + # The sanitizer builds run slowly under Clang. CodeCov crashes under Clang. - compiler: clang env: BUILD_MODE="asan" - compiler: clang env: BUILD_MODE="ubsan" + - compiler: clang + env: BUILD_MODE="codecov" script: - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all From cab2b5a1815dd6d84ee4a2563be540fc044b38a0 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 05:16:09 -0400 Subject: [PATCH 27/49] Reduce optimizations for code coverage recipes --- GNUmakefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/GNUmakefile b/GNUmakefile index 01342db4..a69319e4 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -406,6 +406,9 @@ endif # Gold # lcov code coverage. Issue 'make coverage'. ifneq ($(filter coverage,$(MAKECMDGOALS)),) +CXXFLAGS := $(CXXFLAGS:-g%=-g3) +CXXFLAGS := $(CXXFLAGS:-O%=-O1) +CXXFLAGS := $(CXXFLAGS:-xO%=-xO1) ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),) CXXFLAGS += -DCRYPTOPP_COVERAGE endif # CRYPTOPP_COVERAGE @@ -416,6 +419,9 @@ endif # GCC code coverage # gcov code coverage for Travis. Issue 'make codecov'. ifneq ($(filter codecov,$(MAKECMDGOALS)),) +CXXFLAGS := $(CXXFLAGS:-g%=-g3) +CXXFLAGS := $(CXXFLAGS:-O%=-O1) +CXXFLAGS := $(CXXFLAGS:-xO%=-xO1) ifeq ($(findstring -DCRYPTOPP_COVERAGE,$(CXXFLAGS)),) CXXFLAGS += -DCRYPTOPP_COVERAGE endif # CRYPTOPP_COVERAGE From ea3ea9deb5a178c5746df44f6c1ccd4652984135 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 05:50:01 -0400 Subject: [PATCH 28/49] Add missing semi-colon --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cdb06f33..41a1899f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ script: - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all after_success: - - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then bash <(curl -s https://codecov.io/bash) fi; + - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then bash <(curl -s https://codecov.io/bash); fi; # whitelist branches to avoid testing feature branches twice branches: From 0885ce2bcc52f1db626e924ee055d78f32281e04 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 06:41:02 -0400 Subject: [PATCH 29/49] Attempt to add Code Coverage report (Take 5) This should be interesting... --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 41a1899f..1bab130a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ script: - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all after_success: - - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then bash <(curl -s https://codecov.io/bash); fi; + - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then CODECOV_TOKEN="5c7bc59c-e95f-4594-82c3-33e7a1942592" bash <(curl -s https://codecov.io/bash); fi; # whitelist branches to avoid testing feature branches twice branches: From a139d6a8461e7057369e04ab93655945b1266db8 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 07:02:44 -0400 Subject: [PATCH 30/49] Cleanup gcov artifacts in clean rule --- GNUmakefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index a69319e4..09b9ffb2 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -405,7 +405,7 @@ endif # CXXFLAGS endif # Gold # lcov code coverage. Issue 'make coverage'. -ifneq ($(filter coverage,$(MAKECMDGOALS)),) +ifneq ($(filter lcov coverage,$(MAKECMDGOALS)),) CXXFLAGS := $(CXXFLAGS:-g%=-g3) CXXFLAGS := $(CXXFLAGS:-O%=-O1) CXXFLAGS := $(CXXFLAGS:-xO%=-xO1) @@ -418,7 +418,7 @@ endif # -coverage endif # GCC code coverage # gcov code coverage for Travis. Issue 'make codecov'. -ifneq ($(filter codecov,$(MAKECMDGOALS)),) +ifneq ($(filter gcov codecov,$(MAKECMDGOALS)),) CXXFLAGS := $(CXXFLAGS:-g%=-g3) CXXFLAGS := $(CXXFLAGS:-O%=-O1) CXXFLAGS := $(CXXFLAGS:-xO%=-xO1) @@ -563,8 +563,8 @@ no-asm asan ubsan: libcryptopp.a cryptest.exe lean: static dynamic cryptest.exe # May want to export CXXFLAGS="-g3 -O1" -.PHONY: coverage -coverage: libcryptopp.a cryptest.exe +.PHONY: lcov coverage +lcov coverage: libcryptopp.a cryptest.exe @-$(RM) -r ./TestCoverage/ lcov --base-directory . --directory . --zerocounters -q ./cryptest.exe v @@ -574,8 +574,8 @@ coverage: libcryptopp.a cryptest.exe genhtml -o ./TestCoverage/ -t "cryptest.exe test coverage" --num-spaces 4 cryptest.info # Travis CI and CodeCov rule -.PHONY: codecov -codecov: libcryptopp.a cryptest.exe +.PHONY: gcov codecov +gcov codecov: libcryptopp.a cryptest.exe @-$(RM) -r ./TestCoverage/ ./cryptest.exe v ./cryptest.exe tv all @@ -623,7 +623,7 @@ clean: @-$(RM) libcryptopp.a libcryptopp.dylib cryptopp.dll libcryptopp.dll.a libcryptopp.import.a @-$(RM) libcryptopp.so libcryptopp.so$(SOLIB_COMPAT_SUFFIX) libcryptopp.so$(SOLIB_VERSION_SUFFIX) @-$(RM) cryptest.exe dlltest.exe cryptest.import.exe cryptest.info ct - @-$(RM) *.gcno *.gcda *.stackdump core-* + @-$(RM) *.gcov *.gcno *.gcda *.stackdump core-* @-$(RM) /tmp/adhoc.exe @-$(RM) -r /tmp/cryptopp_test/ @-$(RM) -r *.exe.dSYM/ From 814de0f0c722f90f2ed27a53fb0325c063fe6443 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 27 May 2017 07:18:48 -0400 Subject: [PATCH 31/49] Use "relative" option for gcov recipe --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 09b9ffb2..93c8a853 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -579,7 +579,7 @@ gcov codecov: libcryptopp.a cryptest.exe @-$(RM) -r ./TestCoverage/ ./cryptest.exe v ./cryptest.exe tv all - gcov $(SRCS) + gcov -r $(SRCS) # Should use CXXFLAGS="-g3 -O1" .PHONY: valgrind From b120276f3ecc63e0b38a657b3172b7cd585d42d4 Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Sun, 28 May 2017 01:17:28 -0400 Subject: [PATCH 32/49] Define matrix exclusion (#432) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1bab130a..7853403a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,7 +27,7 @@ env: - BUILD_MODE="asan" - BUILD_MODE="ubsan" - BUILD_MODE="codecov" - +matrix: exclude: # Skip GCC on OS X entirely - os: osx From 567e4f31b447ffee449f296ee93dda13f8c996a4 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 28 May 2017 02:42:40 -0400 Subject: [PATCH 33/49] Update travis.yml for Clang, GCC and OS X Thanks to Hiro Asari on the Travis GitHub for helping with the last of the issues --- .travis.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7853403a..73036cf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,22 +27,23 @@ env: - BUILD_MODE="asan" - BUILD_MODE="ubsan" - BUILD_MODE="codecov" + matrix: exclude: # Skip GCC on OS X entirely - os: osx compiler: gcc - - # The sanitizer builds run slowly under Clang. CodeCov crashes under Clang. - - compiler: clang - env: BUILD_MODE="asan" - - compiler: clang - env: BUILD_MODE="ubsan" + # CodeCov crashes under Clang - compiler: clang env: BUILD_MODE="codecov" + allow_failures: + # Ignore problems with old toolchains + - env: BUILD_MODE="ubsan" + - env: BUILD_MODE="asan" + script: - - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all + - travis_wait make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all after_success: - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then CODECOV_TOKEN="5c7bc59c-e95f-4594-82c3-33e7a1942592" bash <(curl -s https://codecov.io/bash); fi; From 81c751314b266c0ae3944e6125f05d244915defe Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 28 May 2017 16:11:28 -0400 Subject: [PATCH 34/49] Add reset-fork script to testing --- TestScripts/reset-fork.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 TestScripts/reset-fork.sh diff --git a/TestScripts/reset-fork.sh b/TestScripts/reset-fork.sh new file mode 100644 index 00000000..ab25b9fe --- /dev/null +++ b/TestScripts/reset-fork.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# Use this script to reset a fork to Wei Dai's master +# https://stackoverflow.com/questions/9646167/clean-up-a-fork-and-restart-it-from-the-upstream + +git remote add upstream https://github.com/weidai11/cryptopp 2>/dev/null +git fetch upstream +git checkout master +git reset --hard upstream/master +git push origin master --force From 0df38c3506efbe8aac5ce7a695c01d487348dcc1 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sun, 28 May 2017 17:00:09 -0400 Subject: [PATCH 35/49] Fix build timeout due to tracking vars under UBsan Also see https://stackoverflow.com/q/2954473/608639 and https://stackoverflow.com/q/708807/608639 --- .travis.yml | 3 ++- GNUmakefile | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73036cf3..153e3422 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ env: - BUILD_MODE="codecov" matrix: + exclude: # Skip GCC on OS X entirely - os: osx @@ -43,7 +44,7 @@ matrix: - env: BUILD_MODE="asan" script: - - travis_wait make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all + - make "$BUILD_MODE" && ./cryptest.exe v && ./cryptest.exe tv all after_success: - if [[ ( ("$BUILD_MODE" = "coverage") && ("$CC" = "gcc") ) ]]; then CODECOV_TOKEN="5c7bc59c-e95f-4594-82c3-33e7a1942592" bash <(curl -s https://codecov.io/bash); fi; diff --git a/GNUmakefile b/GNUmakefile index 93c8a853..43ef267a 100755 --- a/GNUmakefile +++ b/GNUmakefile @@ -817,6 +817,13 @@ rdrand-%.o: ./rdrand-nasm.sh endif +# Don't build Threefish with UBsan on Travis CI. Timeouts cause the build to fail. +# Also see https://stackoverflow.com/q/12983137/608639. +ifeq ($(findstring true,$(CI)),true) +threefish.o : threefish.cpp + $(CXX) $(strip $(subst -fsanitize=undefined,,$(CXXFLAGS))) -c $< +endif + # Don't build Rijndael with UBsan. Too much noise due to unaligned data accesses. ifneq ($(findstring -fsanitize=undefined,$(CXXFLAGS)),) rijndael.o : rijndael.cpp From ae3922dda0c4c7d75381f2b74425c34adb762c5f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 29 May 2017 00:43:20 -0400 Subject: [PATCH 36/49] Remove calls to cout.flush() for AppVeyor They seemed to produce a hang when running self tests in AppVeyor. Also use IsDebuggerPresent() to determine when we should call DebugBreak(). The OS killed our debug build when fuzzing caused an assert to fail --- trap.h | 7 +++---- validat0.cpp | 11 ++--------- validat1.cpp | 10 ++++------ validate.h | 3 ++- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/trap.h b/trap.h index 46e6598b..0508447d 100644 --- a/trap.h +++ b/trap.h @@ -23,9 +23,8 @@ # if defined(UNIX_SIGNALS_AVAILABLE) # include "ossig.h" # elif defined(CRYPTOPP_WIN32_AVAILABLE) && !defined(__CYGWIN__) -# if (_MSC_VER >= 1400) -# include -# endif + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); # endif #endif // CRYPTOPP_DEBUG @@ -80,7 +79,7 @@ << (int)(__LINE__) << "): " << (char*)(__FUNCTION__) \ << std::endl; \ std::cerr << oss.str(); \ - __debugbreak(); \ + if (IsDebuggerPresent()) {DebugBreak();} \ } \ } #endif // DEBUG and Unix or Windows diff --git a/validat0.cpp b/validat0.cpp index c4a25c76..a0aa9e61 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -141,9 +141,6 @@ bool TestPolynomialMod2() std::cout << (!pass2 ? "FAILED" : "passed") << ": " << "0x" << std::hex << word(SIZE_MAX) << std::dec << " shifted over range [" << start << "," << stop << "]" << "\n"; std::cout << (!pass3 ? "FAILED" : "passed") << ": " << "random values shifted over range [" << std::dec << start << "," << stop << "]" << "\n"; - if (!(pass1 && pass2 && pass3)) - std::cout.flush(); - return pass1 && pass2 && pass3; } #endif @@ -428,7 +425,6 @@ bool TestCompressors() // ************************************************************** - std::cout.flush(); return !fail1 && !fail2 && !fail3; } @@ -684,6 +680,7 @@ bool TestSharing() vector_member_ptrs strSources(threshold); channel.resize(CHID_LENGTH); + for (unsigned int i=0; i Date: Mon, 29 May 2017 02:44:55 -0400 Subject: [PATCH 37/49] Use consistent names like MinEntropyLength() Avoid member function names like GetMinEntropy() --- bench1.cpp | 2 +- drbg.h | 56 +++++++++++++++++++++++++++--------------------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/bench1.cpp b/bench1.cpp index d288cdc7..94173005 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -235,7 +235,7 @@ void BenchMark(const char *name, NIST_DRBG &rng, double timeTotal) Test::GlobalRNG().GenerateBlock(buf, BUF_SIZE); buf.SetMark(16); - rng.IncorporateEntropy(buf, rng.GetMinEntropy()); + rng.IncorporateEntropy(buf, rng.MinEntropyLength()); unsigned long long blocks = 1; double timeTaken; diff --git a/drbg.h b/drbg.h index e7262138..468b8b1c 100644 --- a/drbg.h +++ b/drbg.h @@ -86,13 +86,13 @@ public: //! \brief Provides the security strength //! \returns The security strength of the generator, in bytes //! \details The equivalent class constant is SECURITY_STRENGTH - virtual unsigned int GetSecurityStrength() const=0; + virtual unsigned int SecurityStrength() const=0; //! \brief Provides the seed length //! \returns The seed size of the generator, in bytes //! \details The equivalent class constant is SEED_LENGTH. The size is //! used to maintain internal state of V and C. - virtual unsigned int GetSeedLength() const=0; + virtual unsigned int SeedLength() const=0; //! \brief Provides the minimum entropy size //! \returns The minimum entropy size required by the generator, in bytes @@ -100,7 +100,7 @@ public: //! be instaniated with at least MINIMUM_ENTROPY bytes of entropy. The bytes must //! meet NIST SP 800-90B or //! SP 800-90C requirements. - virtual unsigned int GetMinEntropy() const=0; + virtual unsigned int MinEntropyLength() const=0; //! \brief Provides the maximum entropy size //! \returns The maximum entropy size that can be consumed by the generator, in bytes @@ -108,14 +108,14 @@ public: //! meet NIST SP 800-90B or //! SP 800-90C requirements. MAXIMUM_ENTROPY has been reduced from //! 235 to INT_MAX to fit the underlying C++ datatype. - virtual unsigned int GetMaxEntropy() const=0; + virtual unsigned int MaxEntropyLength() const=0; //! \brief Provides the minimum nonce size //! \returns The minimum nonce size recommended for the generator, in bytes //! \details The equivalent class constant is MINIMUM_NONCE. If a nonce is not //! required then MINIMUM_NONCE is 0. Hash_DRBG does not require a //! nonce, while HMAC_DRBG and CTR_DRBG require a nonce. - virtual unsigned int GetMinNonce() const=0; + virtual unsigned int MinNonceLength() const=0; //! \brief Provides the maximum nonce size //! \returns The maximum nonce that can be consumed by the generator, in bytes @@ -123,19 +123,19 @@ public: //! has been reduced from 235 to INT_MAX to fit the underlying C++ datatype. //! If a nonce is not required then MINIMUM_NONCE is 0. Hash_DRBG does not //! require a nonce, while HMAC_DRBG and CTR_DRBG require a nonce. - virtual unsigned int GetMaxNonce() const=0; + virtual unsigned int MaxNonceLength() const=0; //! \brief Provides the maximum size of a request to GenerateBlock //! \returns The the maximum size of a request to GenerateBlock(), in bytes //! \details The equivalent class constant is MAXIMUM_BYTES_PER_REQUEST - virtual unsigned int GetMaxBytesPerRequest() const=0; + virtual unsigned int MaxBytesPerRequest() const=0; //! \brief Provides the maximum number of requests before a reseed //! \returns The the maximum number of requests before a reseed, in bytes //! \details The equivalent class constant is MAXIMUM_REQUESTS_BEFORE_RESEED. //! MAXIMUM_REQUESTS_BEFORE_RESEED has been reduced from 248 to INT_MAX //! to fit the underlying C++ datatype. - virtual unsigned int GetMaxRequestBeforeReseed() const=0; + virtual unsigned int MaxRequestBeforeReseed() const=0; protected: virtual void DRBG_Instantiate(const byte* entropy, size_t entropyLength, @@ -213,14 +213,14 @@ public: DRBG_Instantiate(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); } - unsigned int GetSecurityStrength() const {return SECURITY_STRENGTH;} - unsigned int GetSeedLength() const {return SEED_LENGTH;} - unsigned int GetMinEntropy() const {return MINIMUM_ENTROPY;} - unsigned int GetMaxEntropy() const {return MAXIMUM_ENTROPY;} - unsigned int GetMinNonce() const {return MINIMUM_NONCE;} - unsigned int GetMaxNonce() const {return MAXIMUM_NONCE;} - unsigned int GetMaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} - unsigned int GetMaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} + unsigned int SecurityStrength() const {return SECURITY_STRENGTH;} + unsigned int SeedLength() const {return SEED_LENGTH;} + unsigned int MinEntropyLength() const {return MINIMUM_ENTROPY;} + unsigned int MaxEntropyLength() const {return MAXIMUM_ENTROPY;} + unsigned int MinNonceLength() const {return MINIMUM_NONCE;} + unsigned int MaxNonceLength() const {return MAXIMUM_NONCE;} + unsigned int MaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} + unsigned int MaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} void IncorporateEntropy(const byte *input, size_t length) {return DRBG_Reseed(input, length, NULLPTR, 0);} @@ -327,14 +327,14 @@ public: DRBG_Instantiate(entropy, entropyLength, nonce, nonceLength, personalization, personalizationLength); } - unsigned int GetSecurityStrength() const {return SECURITY_STRENGTH;} - unsigned int GetSeedLength() const {return SEED_LENGTH;} - unsigned int GetMinEntropy() const {return MINIMUM_ENTROPY;} - unsigned int GetMaxEntropy() const {return MAXIMUM_ENTROPY;} - unsigned int GetMinNonce() const {return MINIMUM_NONCE;} - unsigned int GetMaxNonce() const {return MAXIMUM_NONCE;} - unsigned int GetMaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} - unsigned int GetMaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} + unsigned int SecurityStrength() const {return SECURITY_STRENGTH;} + unsigned int SeedLength() const {return SEED_LENGTH;} + unsigned int MinEntropyLength() const {return MINIMUM_ENTROPY;} + unsigned int MaxEntropyLength() const {return MAXIMUM_ENTROPY;} + unsigned int MinNonceLength() const {return MINIMUM_NONCE;} + unsigned int MaxNonceLength() const {return MAXIMUM_NONCE;} + unsigned int MaxBytesPerRequest() const {return MAXIMUM_BYTES_PER_REQUEST;} + unsigned int MaxRequestBeforeReseed() const {return MAXIMUM_REQUESTS_BEFORE_RESEED;} void IncorporateEntropy(const byte *input, size_t length) {return DRBG_Reseed(input, length, NULLPTR, 0);} @@ -435,10 +435,10 @@ template void Hash_DRBG::Hash_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size) { // Step 1 - if (static_cast(m_reseed) >= static_cast(GetMaxRequestBeforeReseed())) + if (static_cast(m_reseed) >= static_cast(MaxRequestBeforeReseed())) throw NIST_DRBG::Err("Hash_DRBG", "Reseed required"); - if (size > GetMaxBytesPerRequest()) + if (size > MaxBytesPerRequest()) throw NIST_DRBG::Err("Hash_DRBG", "Request size exceeds limit"); // SP 800-90A, Section 9, says we should throw if we have too much entropy, too large a nonce, @@ -658,10 +658,10 @@ template void HMAC_DRBG::HMAC_Generate(const byte* additional, size_t additionaLength, byte *output, size_t size) { // Step 1 - if (static_cast(m_reseed) >= static_cast(GetMaxRequestBeforeReseed())) + if (static_cast(m_reseed) >= static_cast(MaxRequestBeforeReseed())) throw NIST_DRBG::Err("HMAC_DRBG", "Reseed required"); - if (size > GetMaxBytesPerRequest()) + if (size > MaxBytesPerRequest()) throw NIST_DRBG::Err("HMAC_DRBG", "Request size exceeds limit"); // SP 800-90A, Section 9, says we should throw if we have too much entropy, too large a nonce, From 52b4cceda58dd424c4788246fbd37bea21362073 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 29 May 2017 21:53:59 -0400 Subject: [PATCH 38/49] Remove extraneous return --- test.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/test.cpp b/test.cpp index b19fbad5..a4e02bc5 100644 --- a/test.cpp +++ b/test.cpp @@ -392,7 +392,6 @@ int CRYPTOPP_API main(int argc, char *argv[]) { FileSource usage(CRYPTOPP_DATA_DIR "TestData/usage.dat", true, new FileSink(std::cout)); return 1; - return 1; } else if (command == "V") { From 23448050c0083f026bed98b00742dbd4c4ae72eb Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 30 May 2017 05:50:57 -0400 Subject: [PATCH 39/49] Export AssignIntToInteger for FIPS DLL builds (Issue 389) --- algparam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algparam.h b/algparam.h index c66fe984..aceaba4e 100644 --- a/algparam.h +++ b/algparam.h @@ -301,7 +301,7 @@ AssignFromHelperClass AssignFromHelper(T *pObject, const NameValuePairs &s #ifndef CRYPTOPP_NO_ASSIGN_TO_INTEGER // Allow the linker to discard Integer code if not needed. // Also see http://github.com/weidai11/cryptopp/issues/389. -bool AssignIntToInteger(const std::type_info &valueType, void *pInteger, const void *pInt); +CRYPTOPP_DLL bool AssignIntToInteger(const std::type_info &valueType, void *pInteger, const void *pInt); #endif CRYPTOPP_DLL const std::type_info & CRYPTOPP_API IntegerTypeId(); From eb3b27a6a5432b21e8e0bb2abb364096b2dca41e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 30 May 2017 16:37:41 -0400 Subject: [PATCH 40/49] Clear Visual Studio warnings (Issue 412) --- algparam.h | 10 ++++++---- bench1.cpp | 8 ++++++++ bench2.cpp | 4 ++++ channels.cpp | 4 ++++ channels.h | 9 +++++++++ config.h | 4 ++++ cryptlib.h | 2 +- datatest.cpp | 4 ++-- dlltest.cpp | 4 ++++ ec2n.h | 9 +++++++++ eccrypto.h | 9 +++++++++ ecp.h | 9 +++++++++ filters.cpp | 2 +- filters.h | 2 +- gf2n.h | 9 +++++++++ gfpcrypt.h | 2 +- iterhash.h | 14 ++++++++++++++ modarith.h | 9 +++++++++ modes.h | 12 ++++++++++++ modexppc.h | 9 +++++++++ regtest1.cpp | 4 ++++ regtest2.cpp | 4 ++++ regtest3.cpp | 4 ++++ secblock.h | 4 ++-- strciphr.h | 2 +- validat0.cpp | 4 ++++ validat1.cpp | 4 ++++ validat2.cpp | 4 ++++ validat3.cpp | 4 ++++ 29 files changed, 156 insertions(+), 13 deletions(-) diff --git a/algparam.h b/algparam.h index aceaba4e..52dc6e27 100644 --- a/algparam.h +++ b/algparam.h @@ -11,10 +11,12 @@ #include "config.h" #include "cryptlib.h" -// TODO: fix 6011 when the API/ABI can change -#if (CRYPTOPP_MSC_VERSION >= 1400) +#if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 6011 28193) +# pragma warning(disable: 4231 4275) +# if (CRYPTOPP_MSC_VERSION >= 1400) +# pragma warning(disable: 6011 6386 28193) +# endif #endif #include "smartptr.h" @@ -301,7 +303,7 @@ AssignFromHelperClass AssignFromHelper(T *pObject, const NameValuePairs &s #ifndef CRYPTOPP_NO_ASSIGN_TO_INTEGER // Allow the linker to discard Integer code if not needed. // Also see http://github.com/weidai11/cryptopp/issues/389. -CRYPTOPP_DLL bool AssignIntToInteger(const std::type_info &valueType, void *pInteger, const void *pInt); +bool AssignIntToInteger(const std::type_info &valueType, void *pInteger, const void *pInt); #endif CRYPTOPP_DLL const std::type_info & CRYPTOPP_API IntegerTypeId(); diff --git a/bench1.cpp b/bench1.cpp index 94173005..2d128648 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -16,6 +16,14 @@ #include "cpu.h" #include "drbg.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4355) +#endif + +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/bench2.cpp b/bench2.cpp index e0853c4a..3d07b2d0 100644 --- a/bench2.cpp +++ b/bench2.cpp @@ -30,6 +30,10 @@ #include "oids.h" #include "randpool.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/channels.cpp b/channels.cpp index 62419fdd..ec7a98a0 100644 --- a/channels.cpp +++ b/channels.cpp @@ -8,6 +8,10 @@ #include "cryptlib.h" #include "channels.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) #if 0 diff --git a/channels.h b/channels.h index deacca0d..9af4b461 100644 --- a/channels.h +++ b/channels.h @@ -12,6 +12,11 @@ #include "smartptr.h" #include "stdcpp.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) #if 0 @@ -131,4 +136,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/config.h b/config.h index d21b0d4a..1dec8b4a 100644 --- a/config.h +++ b/config.h @@ -732,6 +732,8 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL +#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) +#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL #else #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL #endif @@ -746,6 +748,8 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class +#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) +#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class #else #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class #endif diff --git a/cryptlib.h b/cryptlib.h index f2c04267..b855784d 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -99,7 +99,7 @@ and getting us started on the manual. #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189 4702) +# pragma warning(disable: 4127 4189 4505 4702) #endif NAMESPACE_BEGIN(CryptoPP) diff --git a/datatest.cpp b/datatest.cpp index 805fcd03..2f9bcb5f 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -25,8 +25,8 @@ # pragma strict_gs_check (on) #endif -#if defined(__COVERITY__) -extern "C" void __coverity_tainted_data_sanitize__(void *); +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) #endif NAMESPACE_BEGIN(CryptoPP) diff --git a/dlltest.cpp b/dlltest.cpp index 27def6f0..102fd7d0 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -6,6 +6,10 @@ #include "cryptlib.h" #include "filters.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) USING_NAMESPACE(std) diff --git a/ec2n.h b/ec2n.h index 1d4c9824..cc4c0462 100644 --- a/ec2n.h +++ b/ec2n.h @@ -17,6 +17,11 @@ #include "smartptr.h" #include "pubkey.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) //! \class EC2N @@ -123,4 +128,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/eccrypto.h b/eccrypto.h index 2a1836c2..a4bf3e75 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -22,6 +22,11 @@ #include "ecp.h" #include "ec2n.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) //! \brief Elliptic Curve Parameters @@ -665,4 +670,8 @@ CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) //! \brief Polynomial with Coefficients in GF(2) @@ -375,4 +380,8 @@ template<> inline void swap(CryptoPP::PolynomialMod2 &a, CryptoPP::PolynomialMod NAMESPACE_END #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/gfpcrypt.h b/gfpcrypt.h index 974886fa..5addf8ed 100644 --- a/gfpcrypt.h +++ b/gfpcrypt.h @@ -12,7 +12,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4189) +# pragma warning(disable: 4189 4231 4275) #endif #include "cryptlib.h" diff --git a/iterhash.h b/iterhash.h index bdfa05ab..1b3e7cb5 100644 --- a/iterhash.h +++ b/iterhash.h @@ -1,3 +1,5 @@ +// strciphr.h - originally written and placed in the public domain by Wei Dai + #ifndef CRYPTOPP_ITERHASH_H #define CRYPTOPP_ITERHASH_H @@ -6,6 +8,14 @@ #include "misc.h" #include "simple.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +# if (CRYPTOPP_MSC_VERSION >= 1400) +# pragma warning(disable: 6011 6386 28193) +# endif +#endif + NAMESPACE_BEGIN(CryptoPP) //! \class HashInputTooLong @@ -179,4 +189,8 @@ protected: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/modarith.h b/modarith.h index 5fff4275..1a78f535 100644 --- a/modarith.h +++ b/modarith.h @@ -14,6 +14,11 @@ #include "secblock.h" #include "misc.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup; @@ -313,4 +318,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/modes.h b/modes.h index 0955c3bd..05be7b52 100644 --- a/modes.h +++ b/modes.h @@ -20,6 +20,14 @@ # pragma GCC diagnostic ignored "-Wsign-conversion" #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +# if (CRYPTOPP_MSC_VERSION >= 1400) +# pragma warning(disable: 6011 6386 28193) +# endif +#endif + NAMESPACE_BEGIN(CryptoPP) //! \class CipherModeDocumentation @@ -475,6 +483,10 @@ struct CBC_CTS_Mode_ExternalCipher : public CipherModeDocumentation NAMESPACE_END // Issue 340 +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic pop #endif diff --git a/modexppc.h b/modexppc.h index c2978871..5e8dd676 100644 --- a/modexppc.h +++ b/modexppc.h @@ -9,6 +9,11 @@ #include "smartptr.h" #include "pubkey.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl; @@ -36,4 +41,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/regtest1.cpp b/regtest1.cpp index c4eb7380..86780e69 100644 --- a/regtest1.cpp +++ b/regtest1.cpp @@ -34,6 +34,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) // Unkeyed ciphers diff --git a/regtest2.cpp b/regtest2.cpp index d7a1d58c..8779c113 100644 --- a/regtest2.cpp +++ b/regtest2.cpp @@ -61,6 +61,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) // Shared key ciphers diff --git a/regtest3.cpp b/regtest3.cpp index 292bd544..7949c846 100644 --- a/regtest3.cpp +++ b/regtest3.cpp @@ -26,6 +26,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) void RegisterFactories3() diff --git a/secblock.h b/secblock.h index 73706897..8f5aa71a 100644 --- a/secblock.h +++ b/secblock.h @@ -12,9 +12,9 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4700) +# pragma warning(disable: 4231 4275 4700) # if (CRYPTOPP_MSC_VERSION >= 1400) -# pragma warning(disable: 6386) +# pragma warning(disable: 6011 6386 28193) # endif #endif diff --git a/strciphr.h b/strciphr.h index 83be614c..ff7cca67 100644 --- a/strciphr.h +++ b/strciphr.h @@ -32,7 +32,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189) +# pragma warning(disable: 4127 4189 4231 4275) #endif #include "cryptlib.h" diff --git a/validat0.cpp b/validat0.cpp index a0aa9e61..4b482c03 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -31,6 +31,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat1.cpp b/validat1.cpp index 50d6911d..c10efdf4 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -64,6 +64,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat2.cpp b/validat2.cpp index cc505edd..3d984e92 100644 --- a/validat2.cpp +++ b/validat2.cpp @@ -51,6 +51,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat3.cpp b/validat3.cpp index 829840b0..81257ec8 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -44,6 +44,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) From 8988e36a48e9ce3d1f8971a09d6758bb324f6f1e Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 30 May 2017 16:59:29 -0400 Subject: [PATCH 41/49] Re-add CRYPTOPP_DLL to AssignIntToInteger It looks like it was accidentally blown out at commit eb3b27a6a543 --- algparam.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/algparam.h b/algparam.h index 52dc6e27..95399615 100644 --- a/algparam.h +++ b/algparam.h @@ -303,7 +303,7 @@ AssignFromHelperClass AssignFromHelper(T *pObject, const NameValuePairs &s #ifndef CRYPTOPP_NO_ASSIGN_TO_INTEGER // Allow the linker to discard Integer code if not needed. // Also see http://github.com/weidai11/cryptopp/issues/389. -bool AssignIntToInteger(const std::type_info &valueType, void *pInteger, const void *pInt); +CRYPTOPP_DLL bool AssignIntToInteger(const std::type_info &valueType, void *pInteger, const void *pInt); #endif CRYPTOPP_DLL const std::type_info & CRYPTOPP_API IntegerTypeId(); From a33504c8f8652d5591848b6532fe3dd2cd324b05 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 31 May 2017 04:36:31 -0400 Subject: [PATCH 42/49] Add notification address of cryptopp-build@googlegroups.com Its a new Google Group created at https://groups.google.com/forum/#!forum/cryptopp-build. The list should allow us to run services on unprivileged forks and other unrelated accounts while making it easy to find results. --- .appveyor.yml | 3 +++ .travis.yml | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index ed8bd77f..edfe8d4a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -51,3 +51,6 @@ matrix: configuration: Release - image: Visual Studio 2010 - image: Visual Studio 2017 + +notifications: + email: cryptopp-build@googlegroups.com diff --git a/.travis.yml b/.travis.yml index 153e3422..ea073db8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -62,5 +62,5 @@ addons: name: "cryptopp" build_command: "make -j 2" -#notifications: -# email: jdoe@example.com +notifications: + email: cryptopp-build@googlegroups.com From dd42fa3ef63ee2ac8d335c3e261aa7c4d030d292 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Wed, 31 May 2017 07:22:04 -0400 Subject: [PATCH 43/49] Add notification address of cryptopp-build@googlegroups.com (Take 2) --- .appveyor.yml | 6 +++++- .travis.yml | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index edfe8d4a..5ca48d45 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -53,4 +53,8 @@ matrix: - image: Visual Studio 2017 notifications: - email: cryptopp-build@googlegroups.com + email: + recipients: + - cryptopp-build@googlegroups.com + on_success: always # default: change + on_failure: always # default: always diff --git a/.travis.yml b/.travis.yml index ea073db8..1f8e90e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,4 +63,8 @@ addons: build_command: "make -j 2" notifications: - email: cryptopp-build@googlegroups.com + email: + recipients: + - cryptopp-build@googlegroups.com + on_success: always # default: change + on_failure: always # default: always \ No newline at end of file From c3871aec948013c1a4d5613050c659520f59e2e4 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 2 Jun 2017 05:06:56 -0400 Subject: [PATCH 44/49] Revert "Clear Visual Studio warnings (Issue 412)" This reverts commit eb3b27a6a543. The change broke GCC 4.8 and unknown version of Clang on OS X. UB reported the OS X break, and JW found duplicated the break on a ARM CubieTruck with GCC 4.8. --- algparam.h | 8 +++----- bench1.cpp | 8 -------- bench2.cpp | 4 ---- channels.cpp | 4 ---- channels.h | 9 --------- config.h | 4 ---- cryptlib.h | 2 +- datatest.cpp | 4 ++-- dlltest.cpp | 4 ---- ec2n.h | 9 --------- eccrypto.h | 9 --------- ecp.h | 9 --------- filters.cpp | 2 +- filters.h | 2 +- gf2n.h | 9 --------- gfpcrypt.h | 2 +- iterhash.h | 14 -------------- modarith.h | 9 --------- modes.h | 12 ------------ modexppc.h | 9 --------- regtest1.cpp | 4 ---- regtest2.cpp | 4 ---- regtest3.cpp | 4 ---- secblock.h | 4 ++-- strciphr.h | 2 +- validat0.cpp | 4 ---- validat1.cpp | 4 ---- validat2.cpp | 4 ---- validat3.cpp | 4 ---- 29 files changed, 12 insertions(+), 155 deletions(-) diff --git a/algparam.h b/algparam.h index 95399615..aceaba4e 100644 --- a/algparam.h +++ b/algparam.h @@ -11,12 +11,10 @@ #include "config.h" #include "cryptlib.h" -#if CRYPTOPP_MSC_VERSION +// TODO: fix 6011 when the API/ABI can change +#if (CRYPTOPP_MSC_VERSION >= 1400) # pragma warning(push) -# pragma warning(disable: 4231 4275) -# if (CRYPTOPP_MSC_VERSION >= 1400) -# pragma warning(disable: 6011 6386 28193) -# endif +# pragma warning(disable: 6011 28193) #endif #include "smartptr.h" diff --git a/bench1.cpp b/bench1.cpp index 2d128648..94173005 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -16,14 +16,6 @@ #include "cpu.h" #include "drbg.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4355) -#endif - -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/bench2.cpp b/bench2.cpp index 3d07b2d0..e0853c4a 100644 --- a/bench2.cpp +++ b/bench2.cpp @@ -30,10 +30,6 @@ #include "oids.h" #include "randpool.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/channels.cpp b/channels.cpp index ec7a98a0..62419fdd 100644 --- a/channels.cpp +++ b/channels.cpp @@ -8,10 +8,6 @@ #include "cryptlib.h" #include "channels.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) #if 0 diff --git a/channels.h b/channels.h index 9af4b461..deacca0d 100644 --- a/channels.h +++ b/channels.h @@ -12,11 +12,6 @@ #include "smartptr.h" #include "stdcpp.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) #if 0 @@ -136,8 +131,4 @@ private: NAMESPACE_END -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #endif diff --git a/config.h b/config.h index 1dec8b4a..d21b0d4a 100644 --- a/config.h +++ b/config.h @@ -732,8 +732,6 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL -#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) -#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL #else #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL #endif @@ -748,8 +746,6 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class -#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) -#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class #else #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class #endif diff --git a/cryptlib.h b/cryptlib.h index b855784d..f2c04267 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -99,7 +99,7 @@ and getting us started on the manual. #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189 4505 4702) +# pragma warning(disable: 4127 4189 4702) #endif NAMESPACE_BEGIN(CryptoPP) diff --git a/datatest.cpp b/datatest.cpp index 2f9bcb5f..805fcd03 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -25,8 +25,8 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) +#if defined(__COVERITY__) +extern "C" void __coverity_tainted_data_sanitize__(void *); #endif NAMESPACE_BEGIN(CryptoPP) diff --git a/dlltest.cpp b/dlltest.cpp index 102fd7d0..27def6f0 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -6,10 +6,6 @@ #include "cryptlib.h" #include "filters.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - USING_NAMESPACE(CryptoPP) USING_NAMESPACE(std) diff --git a/ec2n.h b/ec2n.h index cc4c0462..1d4c9824 100644 --- a/ec2n.h +++ b/ec2n.h @@ -17,11 +17,6 @@ #include "smartptr.h" #include "pubkey.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -#endif - NAMESPACE_BEGIN(CryptoPP) //! \class EC2N @@ -128,8 +123,4 @@ private: NAMESPACE_END -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #endif diff --git a/eccrypto.h b/eccrypto.h index a4bf3e75..2a1836c2 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -22,11 +22,6 @@ #include "ecp.h" #include "ec2n.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -#endif - NAMESPACE_BEGIN(CryptoPP) //! \brief Elliptic Curve Parameters @@ -670,8 +665,4 @@ CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -#endif - NAMESPACE_BEGIN(CryptoPP) //! \brief Polynomial with Coefficients in GF(2) @@ -380,8 +375,4 @@ template<> inline void swap(CryptoPP::PolynomialMod2 &a, CryptoPP::PolynomialMod NAMESPACE_END #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #endif diff --git a/gfpcrypt.h b/gfpcrypt.h index 5addf8ed..974886fa 100644 --- a/gfpcrypt.h +++ b/gfpcrypt.h @@ -12,7 +12,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4189 4231 4275) +# pragma warning(disable: 4189) #endif #include "cryptlib.h" diff --git a/iterhash.h b/iterhash.h index 1b3e7cb5..bdfa05ab 100644 --- a/iterhash.h +++ b/iterhash.h @@ -1,5 +1,3 @@ -// strciphr.h - originally written and placed in the public domain by Wei Dai - #ifndef CRYPTOPP_ITERHASH_H #define CRYPTOPP_ITERHASH_H @@ -8,14 +6,6 @@ #include "misc.h" #include "simple.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -# if (CRYPTOPP_MSC_VERSION >= 1400) -# pragma warning(disable: 6011 6386 28193) -# endif -#endif - NAMESPACE_BEGIN(CryptoPP) //! \class HashInputTooLong @@ -189,8 +179,4 @@ protected: NAMESPACE_END -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #endif diff --git a/modarith.h b/modarith.h index 1a78f535..5fff4275 100644 --- a/modarith.h +++ b/modarith.h @@ -14,11 +14,6 @@ #include "secblock.h" #include "misc.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -#endif - NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup; @@ -318,8 +313,4 @@ private: NAMESPACE_END -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #endif diff --git a/modes.h b/modes.h index 05be7b52..0955c3bd 100644 --- a/modes.h +++ b/modes.h @@ -20,14 +20,6 @@ # pragma GCC diagnostic ignored "-Wsign-conversion" #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -# if (CRYPTOPP_MSC_VERSION >= 1400) -# pragma warning(disable: 6011 6386 28193) -# endif -#endif - NAMESPACE_BEGIN(CryptoPP) //! \class CipherModeDocumentation @@ -483,10 +475,6 @@ struct CBC_CTS_Mode_ExternalCipher : public CipherModeDocumentation NAMESPACE_END // Issue 340 -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic pop #endif diff --git a/modexppc.h b/modexppc.h index 5e8dd676..c2978871 100644 --- a/modexppc.h +++ b/modexppc.h @@ -9,11 +9,6 @@ #include "smartptr.h" #include "pubkey.h" -#if CRYPTOPP_MSC_VERSION -# pragma warning(push) -# pragma warning(disable: 4231 4275) -#endif - NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl; @@ -41,8 +36,4 @@ private: NAMESPACE_END -#if CRYPTOPP_MSC_VERSION -# pragma warning(pop) -#endif - #endif diff --git a/regtest1.cpp b/regtest1.cpp index 86780e69..c4eb7380 100644 --- a/regtest1.cpp +++ b/regtest1.cpp @@ -34,10 +34,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - USING_NAMESPACE(CryptoPP) // Unkeyed ciphers diff --git a/regtest2.cpp b/regtest2.cpp index 8779c113..d7a1d58c 100644 --- a/regtest2.cpp +++ b/regtest2.cpp @@ -61,10 +61,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - USING_NAMESPACE(CryptoPP) // Shared key ciphers diff --git a/regtest3.cpp b/regtest3.cpp index 7949c846..292bd544 100644 --- a/regtest3.cpp +++ b/regtest3.cpp @@ -26,10 +26,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - USING_NAMESPACE(CryptoPP) void RegisterFactories3() diff --git a/secblock.h b/secblock.h index 8f5aa71a..73706897 100644 --- a/secblock.h +++ b/secblock.h @@ -12,9 +12,9 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4231 4275 4700) +# pragma warning(disable: 4700) # if (CRYPTOPP_MSC_VERSION >= 1400) -# pragma warning(disable: 6011 6386 28193) +# pragma warning(disable: 6386) # endif #endif diff --git a/strciphr.h b/strciphr.h index ff7cca67..83be614c 100644 --- a/strciphr.h +++ b/strciphr.h @@ -32,7 +32,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189 4231 4275) +# pragma warning(disable: 4127 4189) #endif #include "cryptlib.h" diff --git a/validat0.cpp b/validat0.cpp index 4b482c03..a0aa9e61 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -31,10 +31,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat1.cpp b/validat1.cpp index c10efdf4..50d6911d 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -64,10 +64,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat2.cpp b/validat2.cpp index 3d984e92..cc505edd 100644 --- a/validat2.cpp +++ b/validat2.cpp @@ -51,10 +51,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat3.cpp b/validat3.cpp index 81257ec8..829840b0 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -44,10 +44,6 @@ # pragma strict_gs_check (on) #endif -#if CRYPTOPP_MSC_VERSION -# pragma warning(disable: 4505 4355) -#endif - NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) From 7ac77ca9ac780a3b027e59d23433a5e1e027e93f Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 2 Jun 2017 05:18:52 -0400 Subject: [PATCH 45/49] Revert "Revert "Clear Visual Studio warnings (Issue 412)"" This reverts commit c3871aec948013c1a4d5613050c659520f59e2e4. --- algparam.h | 8 +++++--- bench1.cpp | 8 ++++++++ bench2.cpp | 4 ++++ channels.cpp | 4 ++++ channels.h | 9 +++++++++ config.h | 4 ++++ cryptlib.h | 2 +- datatest.cpp | 4 ++-- dlltest.cpp | 4 ++++ ec2n.h | 9 +++++++++ eccrypto.h | 9 +++++++++ ecp.h | 9 +++++++++ filters.cpp | 2 +- filters.h | 2 +- gf2n.h | 9 +++++++++ gfpcrypt.h | 2 +- iterhash.h | 14 ++++++++++++++ modarith.h | 9 +++++++++ modes.h | 12 ++++++++++++ modexppc.h | 9 +++++++++ regtest1.cpp | 4 ++++ regtest2.cpp | 4 ++++ regtest3.cpp | 4 ++++ secblock.h | 4 ++-- strciphr.h | 2 +- validat0.cpp | 4 ++++ validat1.cpp | 4 ++++ validat2.cpp | 4 ++++ validat3.cpp | 4 ++++ 29 files changed, 155 insertions(+), 12 deletions(-) diff --git a/algparam.h b/algparam.h index aceaba4e..95399615 100644 --- a/algparam.h +++ b/algparam.h @@ -11,10 +11,12 @@ #include "config.h" #include "cryptlib.h" -// TODO: fix 6011 when the API/ABI can change -#if (CRYPTOPP_MSC_VERSION >= 1400) +#if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 6011 28193) +# pragma warning(disable: 4231 4275) +# if (CRYPTOPP_MSC_VERSION >= 1400) +# pragma warning(disable: 6011 6386 28193) +# endif #endif #include "smartptr.h" diff --git a/bench1.cpp b/bench1.cpp index 94173005..2d128648 100644 --- a/bench1.cpp +++ b/bench1.cpp @@ -16,6 +16,14 @@ #include "cpu.h" #include "drbg.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4355) +#endif + +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/bench2.cpp b/bench2.cpp index e0853c4a..3d07b2d0 100644 --- a/bench2.cpp +++ b/bench2.cpp @@ -30,6 +30,10 @@ #include "oids.h" #include "randpool.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/channels.cpp b/channels.cpp index 62419fdd..ec7a98a0 100644 --- a/channels.cpp +++ b/channels.cpp @@ -8,6 +8,10 @@ #include "cryptlib.h" #include "channels.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) #if 0 diff --git a/channels.h b/channels.h index deacca0d..9af4b461 100644 --- a/channels.h +++ b/channels.h @@ -12,6 +12,11 @@ #include "smartptr.h" #include "stdcpp.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) #if 0 @@ -131,4 +136,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/config.h b/config.h index d21b0d4a..1dec8b4a 100644 --- a/config.h +++ b/config.h @@ -732,6 +732,8 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL +#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) +#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL #else #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL #endif @@ -746,6 +748,8 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class +#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) +#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class #else #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class #endif diff --git a/cryptlib.h b/cryptlib.h index f2c04267..b855784d 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -99,7 +99,7 @@ and getting us started on the manual. #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189 4702) +# pragma warning(disable: 4127 4189 4505 4702) #endif NAMESPACE_BEGIN(CryptoPP) diff --git a/datatest.cpp b/datatest.cpp index 805fcd03..2f9bcb5f 100644 --- a/datatest.cpp +++ b/datatest.cpp @@ -25,8 +25,8 @@ # pragma strict_gs_check (on) #endif -#if defined(__COVERITY__) -extern "C" void __coverity_tainted_data_sanitize__(void *); +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) #endif NAMESPACE_BEGIN(CryptoPP) diff --git a/dlltest.cpp b/dlltest.cpp index 27def6f0..102fd7d0 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -6,6 +6,10 @@ #include "cryptlib.h" #include "filters.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) USING_NAMESPACE(std) diff --git a/ec2n.h b/ec2n.h index 1d4c9824..cc4c0462 100644 --- a/ec2n.h +++ b/ec2n.h @@ -17,6 +17,11 @@ #include "smartptr.h" #include "pubkey.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) //! \class EC2N @@ -123,4 +128,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/eccrypto.h b/eccrypto.h index 2a1836c2..a4bf3e75 100644 --- a/eccrypto.h +++ b/eccrypto.h @@ -22,6 +22,11 @@ #include "ecp.h" #include "ec2n.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) //! \brief Elliptic Curve Parameters @@ -665,4 +670,8 @@ CRYPTOPP_DLL_TEMPLATE_CLASS DL_PrivateKey_WithSignaturePairwiseConsistencyTest +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) //! \brief Polynomial with Coefficients in GF(2) @@ -375,4 +380,8 @@ template<> inline void swap(CryptoPP::PolynomialMod2 &a, CryptoPP::PolynomialMod NAMESPACE_END #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/gfpcrypt.h b/gfpcrypt.h index 974886fa..5addf8ed 100644 --- a/gfpcrypt.h +++ b/gfpcrypt.h @@ -12,7 +12,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4189) +# pragma warning(disable: 4189 4231 4275) #endif #include "cryptlib.h" diff --git a/iterhash.h b/iterhash.h index bdfa05ab..1b3e7cb5 100644 --- a/iterhash.h +++ b/iterhash.h @@ -1,3 +1,5 @@ +// strciphr.h - originally written and placed in the public domain by Wei Dai + #ifndef CRYPTOPP_ITERHASH_H #define CRYPTOPP_ITERHASH_H @@ -6,6 +8,14 @@ #include "misc.h" #include "simple.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +# if (CRYPTOPP_MSC_VERSION >= 1400) +# pragma warning(disable: 6011 6386 28193) +# endif +#endif + NAMESPACE_BEGIN(CryptoPP) //! \class HashInputTooLong @@ -179,4 +189,8 @@ protected: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/modarith.h b/modarith.h index 5fff4275..1a78f535 100644 --- a/modarith.h +++ b/modarith.h @@ -14,6 +14,11 @@ #include "secblock.h" #include "misc.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_DLL_TEMPLATE_CLASS AbstractGroup; @@ -313,4 +318,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/modes.h b/modes.h index 0955c3bd..05be7b52 100644 --- a/modes.h +++ b/modes.h @@ -20,6 +20,14 @@ # pragma GCC diagnostic ignored "-Wsign-conversion" #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +# if (CRYPTOPP_MSC_VERSION >= 1400) +# pragma warning(disable: 6011 6386 28193) +# endif +#endif + NAMESPACE_BEGIN(CryptoPP) //! \class CipherModeDocumentation @@ -475,6 +483,10 @@ struct CBC_CTS_Mode_ExternalCipher : public CipherModeDocumentation NAMESPACE_END // Issue 340 +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #if CRYPTOPP_GCC_DIAGNOSTIC_AVAILABLE # pragma GCC diagnostic pop #endif diff --git a/modexppc.h b/modexppc.h index c2978871..5e8dd676 100644 --- a/modexppc.h +++ b/modexppc.h @@ -9,6 +9,11 @@ #include "smartptr.h" #include "pubkey.h" +#if CRYPTOPP_MSC_VERSION +# pragma warning(push) +# pragma warning(disable: 4231 4275) +#endif + NAMESPACE_BEGIN(CryptoPP) CRYPTOPP_DLL_TEMPLATE_CLASS DL_FixedBasePrecomputationImpl; @@ -36,4 +41,8 @@ private: NAMESPACE_END +#if CRYPTOPP_MSC_VERSION +# pragma warning(pop) +#endif + #endif diff --git a/regtest1.cpp b/regtest1.cpp index c4eb7380..86780e69 100644 --- a/regtest1.cpp +++ b/regtest1.cpp @@ -34,6 +34,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) // Unkeyed ciphers diff --git a/regtest2.cpp b/regtest2.cpp index d7a1d58c..8779c113 100644 --- a/regtest2.cpp +++ b/regtest2.cpp @@ -61,6 +61,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) // Shared key ciphers diff --git a/regtest3.cpp b/regtest3.cpp index 292bd544..7949c846 100644 --- a/regtest3.cpp +++ b/regtest3.cpp @@ -26,6 +26,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + USING_NAMESPACE(CryptoPP) void RegisterFactories3() diff --git a/secblock.h b/secblock.h index 73706897..8f5aa71a 100644 --- a/secblock.h +++ b/secblock.h @@ -12,9 +12,9 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4700) +# pragma warning(disable: 4231 4275 4700) # if (CRYPTOPP_MSC_VERSION >= 1400) -# pragma warning(disable: 6386) +# pragma warning(disable: 6011 6386 28193) # endif #endif diff --git a/strciphr.h b/strciphr.h index 83be614c..ff7cca67 100644 --- a/strciphr.h +++ b/strciphr.h @@ -32,7 +32,7 @@ #if CRYPTOPP_MSC_VERSION # pragma warning(push) -# pragma warning(disable: 4127 4189) +# pragma warning(disable: 4127 4189 4231 4275) #endif #include "cryptlib.h" diff --git a/validat0.cpp b/validat0.cpp index a0aa9e61..4b482c03 100644 --- a/validat0.cpp +++ b/validat0.cpp @@ -31,6 +31,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat1.cpp b/validat1.cpp index 50d6911d..c10efdf4 100644 --- a/validat1.cpp +++ b/validat1.cpp @@ -64,6 +64,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat2.cpp b/validat2.cpp index cc505edd..3d984e92 100644 --- a/validat2.cpp +++ b/validat2.cpp @@ -51,6 +51,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) diff --git a/validat3.cpp b/validat3.cpp index 829840b0..81257ec8 100644 --- a/validat3.cpp +++ b/validat3.cpp @@ -44,6 +44,10 @@ # pragma strict_gs_check (on) #endif +#if CRYPTOPP_MSC_VERSION +# pragma warning(disable: 4505 4355) +#endif + NAMESPACE_BEGIN(CryptoPP) NAMESPACE_BEGIN(Test) From 429047a8e9765896178d2254c5469b4a5f036d67 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Fri, 2 Jun 2017 07:13:43 -0400 Subject: [PATCH 46/49] Clear Visual Studio warnings (Issue 412) --- config.h | 4 ---- iterhash.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/config.h b/config.h index 1dec8b4a..d21b0d4a 100644 --- a/config.h +++ b/config.h @@ -732,8 +732,6 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern class CRYPTOPP_DLL #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL -#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) -#define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS template class CRYPTOPP_DLL #else #define CRYPTOPP_EXTERN_DLL_TEMPLATE_CLASS extern template class CRYPTOPP_DLL #endif @@ -748,8 +746,6 @@ NAMESPACE_END #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern class #elif defined(__BORLANDC__) || defined(__SUNPRO_CC) #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class -#elif !defined(CRYPTOPP_IMPORTS) && !defined(CRYPTOPP_EXPORTS) -#define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS template class #else #define CRYPTOPP_EXTERN_STATIC_TEMPLATE_CLASS extern template class #endif diff --git a/iterhash.h b/iterhash.h index 1b3e7cb5..5ab38825 100644 --- a/iterhash.h +++ b/iterhash.h @@ -1,4 +1,4 @@ -// strciphr.h - originally written and placed in the public domain by Wei Dai +// iterhash.h - originally written and placed in the public domain by Wei Dai #ifndef CRYPTOPP_ITERHASH_H #define CRYPTOPP_ITERHASH_H From 1565020bfd7f8857e47159dd4064211a3adb8e4b Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 6 Jun 2017 09:39:46 -0400 Subject: [PATCH 47/49] Guard use of X86 ASM for ARM, MIPS and other platforms In the bigger picture, the code to use inline ASM when intrinsics are not available still needs to be checked-in. Its a big change since we moved into SSE4, AVX and SHA. Design changes are still being evaluated, and its still being tested. --- crc.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crc.cpp b/crc.cpp index 52c2b0e6..e1b51bb9 100644 --- a/crc.cpp +++ b/crc.cpp @@ -13,7 +13,7 @@ NAMESPACE_BEGIN(CryptoPP) # undef CRYPTOPP_BOOL_SSE4_INTRINSICS_AVAILABLE #endif -// Use inline ASM to provide the instructions when the user omits -march=native or -msse4.2 +#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 #if (CRYPTOPP_GCC_VERSION >= 40300 || __INTEL_COMPILER >= 1000 || __SUNPRO_CC >= 0x5110 || CRYPTOPP_LLVM_CLANG_VERSION >= 20300 || CRYPTOPP_APPLE_CLANG_VERSION >= 40000) && !defined(__SSE4_2__) GCC_INLINE unsigned int GCC_INLINE_ATTRIB MM_CRC32_U8(unsigned int crc, unsigned char val) @@ -38,6 +38,7 @@ MM_CRC32_U32(unsigned int crc, unsigned int val) #define MM_CRC32_U16(a,b) _mm_crc32_u16(a,b) #define MM_CRC32_U32(a,b) _mm_crc32_u32(a,b) #endif +#endif // X86/X32/X64 /* Table of CRC-32's of all single byte values (made by makecrc.c) */ const word32 CRC32::m_tab[] = { From aaf62695fc03bf941ec51e40a139f5e0eb8652f3 Mon Sep 17 00:00:00 2001 From: "Romain Geissler @ Amadeus" Date: Sun, 18 Jun 2017 21:22:32 +0200 Subject: [PATCH 48/49] Fix C++17 build (PR 437) --- dlltest.cpp | 49 ++++++++++++++++++++++++------------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/dlltest.cpp b/dlltest.cpp index 102fd7d0..e46ccdd5 100644 --- a/dlltest.cpp +++ b/dlltest.cpp @@ -11,23 +11,22 @@ #endif USING_NAMESPACE(CryptoPP) -USING_NAMESPACE(std) void FIPS140_SampleApplication() { if (!FIPS_140_2_ComplianceEnabled()) { - cerr << "FIPS 140-2 compliance was turned off at compile time.\n"; + std::cerr << "FIPS 140-2 compliance was turned off at compile time.\n"; abort(); } // check self test status if (GetPowerUpSelfTestStatus() != POWER_UP_SELF_TEST_PASSED) { - cerr << "Automatic power-up self test failed.\n"; + std::cerr << "Automatic power-up self test failed.\n"; abort(); } - cout << "0. Automatic power-up self test passed.\n"; + std::cout << "0. Automatic power-up self test passed.\n"; // simulate a power-up self test error SimulatePowerUpSelfTestFailure(); @@ -37,23 +36,23 @@ void FIPS140_SampleApplication() AES::Encryption aes; // should not be here - cerr << "Use of AES failed to cause an exception after power-up self test error.\n"; + std::cerr << "Use of AES failed to cause an exception after power-up self test error.\n"; abort(); } catch (SelfTestFailure &e) { - cout << "1. Caught expected exception when simulating self test failure. Exception message follows: "; - cout << e.what() << endl; + std::cout << "1. Caught expected exception when simulating self test failure. Exception message follows: "; + std::cout << e.what() << std::endl; } // clear the self test error state and redo power-up self test DoDllPowerUpSelfTest(); if (GetPowerUpSelfTestStatus() != POWER_UP_SELF_TEST_PASSED) { - cerr << "Re-do power-up self test failed.\n"; + std::cerr << "Re-do power-up self test failed.\n"; abort(); } - cout << "2. Re-do power-up self test passed.\n"; + std::cout << "2. Re-do power-up self test passed.\n"; // encrypt and decrypt const byte key[] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef, 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; @@ -75,10 +74,10 @@ void FIPS140_SampleApplication() if (memcmp(plaintext, decrypted, 24) != 0) { - cerr << "DES-EDE3-CFB Encryption/decryption failed.\n"; + std::cerr << "DES-EDE3-CFB Encryption/decryption failed.\n"; abort(); } - cout << "3. DES-EDE3-CFB Encryption/decryption succeeded.\n"; + std::cout << "3. DES-EDE3-CFB Encryption/decryption succeeded.\n"; // hash const byte message[] = {'a', 'b', 'c'}; @@ -91,10 +90,10 @@ void FIPS140_SampleApplication() if (memcmp(digest, expectedDigest, 20) != 0) { - cerr << "SHA-1 hash failed.\n"; + std::cerr << "SHA-1 hash failed.\n"; abort(); } - cout << "4. SHA-1 hash succeeded.\n"; + std::cout << "4. SHA-1 hash succeeded.\n"; // create auto-seeded X9.17 RNG object, if available #ifdef OS_RNG_AVAILABLE @@ -111,10 +110,10 @@ void FIPS140_SampleApplication() dsaPublicKey.AssignFrom(dsaPrivateKey); if (!dsaPrivateKey.Validate(rng, 3) || !dsaPublicKey.Validate(rng, 3)) { - cerr << "DSA key generation failed.\n"; + std::cerr << "DSA key generation failed.\n"; abort(); } - cout << "5. DSA key generation succeeded.\n"; + std::cout << "5. DSA key generation succeeded.\n"; // encode DSA key std::string encodedDsaPublicKey, encodedDsaPrivateKey; @@ -129,10 +128,10 @@ void FIPS140_SampleApplication() if (!decodedDsaPrivateKey.Validate(rng, 3) || !decodedDsaPublicKey.Validate(rng, 3)) { - cerr << "DSA key encode/decode failed.\n"; + std::cerr << "DSA key encode/decode failed.\n"; abort(); } - cout << "6. DSA key encode/decode succeeded.\n"; + std::cout << "6. DSA key encode/decode succeeded.\n"; // sign and verify byte signature[40]; @@ -143,20 +142,20 @@ void FIPS140_SampleApplication() DSA::Verifier verifier(dsaPublicKey); if (!verifier.VerifyMessage(message, 3, signature, sizeof(signature))) { - cerr << "DSA signature and verification failed.\n"; + std::cerr << "DSA signature and verification failed.\n"; abort(); } - cout << "7. DSA signature and verification succeeded.\n"; + std::cout << "7. DSA signature and verification succeeded.\n"; // try to verify an invalid signature signature[0] ^= 1; if (verifier.VerifyMessage(message, 3, signature, sizeof(signature))) { - cerr << "DSA signature verification failed to detect bad signature.\n"; + std::cerr << "DSA signature verification failed to detect bad signature.\n"; abort(); } - cout << "8. DSA signature verification successfully detected bad signature.\n"; + std::cout << "8. DSA signature verification successfully detected bad signature.\n"; // try to use an invalid key length try @@ -165,16 +164,16 @@ void FIPS140_SampleApplication() encryption_DES_EDE3_ECB.SetKey(key, 5); // should not be here - cerr << "DES-EDE3 implementation did not detect use of invalid key length.\n"; + std::cerr << "DES-EDE3 implementation did not detect use of invalid key length.\n"; abort(); } catch (InvalidArgument &e) { - cout << "9. Caught expected exception when using invalid key length. Exception message follows: "; - cout << e.what() << endl; + std::cout << "9. Caught expected exception when using invalid key length. Exception message follows: "; + std::cout << e.what() << std::endl; } - cout << "\nFIPS 140-2 Sample Application completed normally.\n"; + std::cout << "\nFIPS 140-2 Sample Application completed normally.\n"; } #ifdef CRYPTOPP_IMPORTS From 32f715f1d723e2bbb78b44fa9e167da64214e2e6 Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Sat, 24 Jun 2017 23:41:20 +0200 Subject: [PATCH 49/49] Fix Windows XP support on Visual Studio 2015+ (#439) When compiling with Visual Studio 2015+, Crypto++ uses CryptoNG by default. CryptoNG is only available on Windows Vista and later and Crypto++ currently ignores if the user explicitly wants to target Windows XP. Unlike with other Windows SDK features, everything compiles, but the application doesn't start on Windows XP because bcrypt.dll is missing. That is an issue when updating Visual Studio because the root cause is hard to find. Making use of CryptoNG when targeting Windows 8+ instead by default, regardless of the Visual Studio version, to fix this. --- config.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.h b/config.h index d21b0d4a..291b1488 100644 --- a/config.h +++ b/config.h @@ -44,10 +44,10 @@ // This macro will be ignored if NO_OS_DEPENDENCE is defined. // #define USE_MS_CNGAPI -// If the user did not make a choice, then select CryptoNG if either -// Visual Studio 2015 is available, or Windows 10 or above is available. +// If the user did not make a choice, then select CryptoNG if +// targeting Windows 8 or above. #if !defined(USE_MS_CRYPTOAPI) && !defined(USE_MS_CNGAPI) -# if (_MSC_VER >= 1900) || ((WINVER >= 0x0A00 /*_WIN32_WINNT_WIN10*/) || (_WIN32_WINNT >= 0x0A00 /*_WIN32_WINNT_WIN10*/)) +# if !defined(_USING_V110_SDK71_) && ((WINVER >= 0x0602 /*_WIN32_WINNT_WIN8*/) || (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)) # define USE_MS_CNGAPI # else # define USE_MS_CRYPTOAPI