diff --git a/TestScripts/cryptest.sh b/TestScripts/cryptest.sh index 0047e55f..f64e649f 100755 --- a/TestScripts/cryptest.sh +++ b/TestScripts/cryptest.sh @@ -1457,8 +1457,26 @@ if [[ ("$HAVE_DISASS" -ne "0" && ("$IS_X86" -ne "0" || "$IS_X64" -ne "0")) ]]; t echo "ERROR: failed to generate sha1msg2 instruction" | tee -a "$TEST_RESULTS" fi + COUNT=$(echo -n "$DISASS_TEXT" | "$GREP" -i -c sha256rnds2) + if [[ ("$COUNT" -eq "0") ]]; then + FAILED=1 + echo "ERROR: failed to generate sha256rnds2 instruction" | tee -a "$TEST_RESULTS" + fi + + COUNT=$(echo -n "$DISASS_TEXT" | "$GREP" -i -c sha256msg1) + if [[ ("$COUNT" -eq "0") ]]; then + FAILED=1 + echo "ERROR: failed to generate sha256msg1 instruction" | tee -a "$TEST_RESULTS" + fi + + COUNT=$(echo -n "$DISASS_TEXT" | "$GREP" -i -c sha256msg2) + if [[ ("$COUNT" -eq "0") ]]; then + FAILED=1 + echo "ERROR: failed to generate sha256msg2 instruction" | tee -a "$TEST_RESULTS" + fi + if [[ ("$FAILED" -eq "0") ]]; then - echo "Verified sha1rnds4, sha1nexte, sha1msg1 and sha1msg2 machine instructions" | tee -a "$TEST_RESULTS" + echo "Verified sha1rnds4, sha1nexte, sha1msg1, sha1msg2, sha256rnds2, sha256msg1 and sha256msg2 machine instructions" | tee -a "$TEST_RESULTS" else if [[ ("$CLANG_COMPILER" -ne "0" && "$CLANG_37_OR_ABOVE" -eq "0") ]]; then echo "This could be due to Clang and lack of expected support for SSSE3 (and above) in some versions of the compiler. If so, try Clang 3.7 or above" diff --git a/cryptest.sh b/cryptest.sh index b2d33aa5..f64e649f 100755 --- a/cryptest.sh +++ b/cryptest.sh @@ -588,7 +588,6 @@ fi # "Modern compiler, old hardware" combinations HAVE_X86_AES=0 -HAVE_X86_SHA=0 HAVE_X86_RDRAND=0 HAVE_X86_RDSEED=0 HAVE_X86_PCLMUL=0 @@ -599,12 +598,6 @@ if [[ ("$IS_X86" -ne "0" || "$IS_X64" -ne "0") && ("$SUN_COMPILER" -eq "0") ]]; HAVE_X86_AES=1 fi - rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 - "$CXX" -DCRYPTOPP_ADHOC_MAIN -msha adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 - if [[ "$?" -eq "0" ]]; then - HAVE_X86_SHA=1 - fi - rm -f "$TMP/adhoc.exe" > /dev/null 2>&1 "$CXX" -DCRYPTOPP_ADHOC_MAIN -mrdrnd adhoc.cpp -o "$TMP/adhoc.exe" > /dev/null 2>&1 if [[ "$?" -eq "0" ]]; then @@ -1860,7 +1853,7 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" fi ############################################ -# Minimum arch with AESNI, RDRAND, RDSEED and SHA +# Minimum arch with AESNI, RDRAND and RDSEED if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" -ne "0") ]]; then X86_OPTS=() @@ -1873,9 +1866,6 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" if [[ "$HAVE_X86_RDSEED" -ne "0" ]]; then X86_OPTS+=("-mrdseed") fi - if [[ "$HAVE_X86_SHA" -ne "0" ]]; then - X86_OPTS+=("-msha") - fi # i586 (lacks MMX, SSE and SSE2; enables X86 hardware) if [[ "$IS_X86" -ne "0" ]]; then @@ -1883,7 +1873,7 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" # Debug build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Debug, i586, AESNI, RDRAND, RDSEED and SHA" | tee -a "$TEST_RESULTS" + echo "Testing: Debug, i586, AESNI, RDRAND and RDSEED" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 @@ -1909,7 +1899,7 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" # Release build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Release, i586, AESNI, RDRAND, RDSEED and SHA" | tee -a "$TEST_RESULTS" + echo "Testing: Release, i586, AESNI, RDRAND and RDSEED" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 @@ -1938,7 +1928,7 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" # Debug build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Debug, SSE2, AESNI, RDRAND, RDSEED and SHA" | tee -a "$TEST_RESULTS" + echo "Testing: Debug, SSE2, AESNI, RDRAND and RDSEED" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 @@ -1964,7 +1954,7 @@ if [[ ("$GCC_COMPILER" -ne "0" || "$CLANG_COMPILER" -ne "0" || "$INTEL_COMPILER" # Release build echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: Release, SSE2, AESNI, RDRAND, RDSEED and SHA" | tee -a "$TEST_RESULTS" + echo "Testing: Release, SSE2, AESNI, RDRAND and RDSEED" | tee -a "$TEST_RESULTS" echo "$MAKE" clean > /dev/null 2>&1 @@ -4820,7 +4810,7 @@ if [[ ("$HAVE_X86_AES" -ne "0" || "$HAVE_X86_RDRAND" -ne "0" || "$HAVE_X86_RDSEE echo echo "************************************" | tee -a "$TEST_RESULTS" - echo "Testing: AES, RDRAND, RDSEED and SHA" | tee -a "$TEST_RESULTS" + echo "Testing: AES, RDRAND and RDSEED" | tee -a "$TEST_RESULTS" echo OPTS=() @@ -4839,9 +4829,6 @@ if [[ ("$HAVE_X86_AES" -ne "0" || "$HAVE_X86_RDRAND" -ne "0" || "$HAVE_X86_RDSEE if [[ "$HAVE_X86_PCLMUL" -ne "0" ]]; then OPTS+=("-mpclmul") fi - if [[ "$HAVE_X86_SHA" -ne "0" ]]; then - OPTS+=("-msha") - fi "$MAKE" clean > /dev/null 2>&1 rm -f adhoc.cpp > /dev/null 2>&1 diff --git a/poly1305.cpp b/poly1305.cpp index d79db9a1..b2a68dd7 100644 --- a/poly1305.cpp +++ b/poly1305.cpp @@ -228,12 +228,12 @@ void Poly1305_Base::HashFinal(byte *mac, size_t size) } else { - FixedSizeAlignedSecBlock t; - PutWord(false, LITTLE_ENDIAN_ORDER, t + 0, h0); - PutWord(false, LITTLE_ENDIAN_ORDER, t + 4, h1); - PutWord(false, LITTLE_ENDIAN_ORDER, t + 8, h2); - PutWord(false, LITTLE_ENDIAN_ORDER, t + 12, h3); - memcpy(mac, t, size); + FixedSizeAlignedSecBlock m; + PutWord(false, LITTLE_ENDIAN_ORDER, m + 0, h0); + PutWord(false, LITTLE_ENDIAN_ORDER, m + 4, h1); + PutWord(false, LITTLE_ENDIAN_ORDER, m + 8, h2); + PutWord(false, LITTLE_ENDIAN_ORDER, m + 12, h3); + memcpy(mac, m, size); } }