summaryrefslogtreecommitdiff
path: root/sha.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2018-08-23 14:42:29 -0400
committerGitHub <noreply@github.com>2018-08-23 14:42:29 -0400
commitafbd3e60f68ff8d9ae1b90d9c3c4eb576f518dbd (patch)
tree99d43bac5e27abb44453e699ae308407f25fba3e /sha.cpp
parente054d36dc88d004efb16f6afe1234b4ea94f995c (diff)
downloadcryptopp-git-afbd3e60f68ff8d9ae1b90d9c3c4eb576f518dbd.tar.gz
Fix alignment on Win32 and Solaris Sparc (PR #709)
These fixes were interesting in a morbid sort of way. I thought the FixedSizeAllocatorWithCleanup specializations faithfully reproduced semantics but I was wrong on Win32 and Sparc. Also see Commit e054d36dc88d. It seems there was another requirement or dependency that we missed, but it was not readily apparent. If I am parsing results correctly (which I may not be), it appears the bit twiddling using 8 byte alignment had more influence on alignment than I originally thought based on use of CRYPTOPP_BOOL_ALIGN16 and T_Align16. Or maybe the alignment attributes specified by CRYPTOPP_ALIGN_DATA are not being honored like they should for stack allocations. This check-in avoids some uses of x86 movdqa (aligned) in favor of movdqu (unaligned). The uses were concentrated on memory operands which were 8-byte aligned instead of 16-byte aligned. It is not clear to me how the specializations lost 8-bytes of alignment. The check-in also enlists CRYPTOPP_ASSERT to tell us when there's a problem so we don't need to go hunting for bugs.
Diffstat (limited to 'sha.cpp')
-rw-r--r--sha.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/sha.cpp b/sha.cpp
index b3ec31a7..73f1797f 100644
--- a/sha.cpp
+++ b/sha.cpp
@@ -1119,7 +1119,8 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL SHA512_HashBlock_SSE2(word64 *state, const
#define SSE2_CombineState(i) \
AS2( movdqu xmm0, [edi+i*16])\
- AS2( paddq xmm0, [ecx+i*16])\
+ AS2( movdqu xmm1, [ecx+i*16])\
+ AS2( paddq xmm0, xmm1)\
AS2( movdqu [ecx+i*16], xmm0)
SSE2_CombineState(0)
@@ -1147,7 +1148,7 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL SHA512_HashBlock_SSE2(word64 *state, const
// ANONYMOUS_NAMESPACE_END
-#endif // CRYPTOPP_SSE2_ASM_AVAILABLE
+#endif // CRYPTOPP_SSE2_ASM_AVAILABLE
ANONYMOUS_NAMESPACE_BEGIN