diff options
author | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2009-07-05 18:10:10 +0000 |
---|---|---|
committer | weidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0> | 2009-07-05 18:10:10 +0000 |
commit | a05533bf95f774fe0fdb94ac874184924892a823 (patch) | |
tree | c36117039e1caf63fecd04a7aa1d95fdd84a3110 | |
parent | 0185d170d45fcf847c85148ecb2d8d1ca3f36e2b (diff) | |
download | cryptopp-a05533bf95f774fe0fdb94ac874184924892a823.tar.gz |
fix incorrect SHA-256 computation on non-SSE2 x86 machines on non-aligned input (reported by
pycryptopp project)
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@470 57ff6487-cd31-0410-9ec3-f628ee90f5f0
-rw-r--r-- | sha.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -273,14 +273,15 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 #endif AS2( mov STATE_SAVE, WORD_REG(cx)) AS2( mov DATA_SAVE, WORD_REG(dx)) - AS2( add WORD_REG(di), WORD_REG(dx)) - AS2( mov DATA_END, WORD_REG(di)) + AS2( lea WORD_REG(ax), [WORD_REG(di) + WORD_REG(dx)]) + AS2( mov DATA_END, WORD_REG(ax)) AS2( mov K_END, WORD_REG(si)) #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_BOOL_X86 AS2( test edi, 1) ASJ( jnz, 2, f) + AS1( dec DWORD PTR K_END) #endif AS2( movdqa xmm0, XMMWORD_PTR [WORD_REG(cx)+0*16]) AS2( movdqa xmm1, XMMWORD_PTR [WORD_REG(cx)+1*16]) @@ -355,7 +356,7 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 ROUND(14, 1, eax, ecx, edi, edx) ROUND(15, 1, ecx, eax, edx, edi) AS2( cmp WORD_REG(si), K_END) - ASJ( jne, 1, b) + ASJ( jl, 1, b) AS2( mov WORD_REG(dx), DATA_SAVE) AS2( add WORD_REG(dx), 64) @@ -364,8 +365,8 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32 #if CRYPTOPP_BOOL_SSE2_ASM_AVAILABLE #if CRYPTOPP_BOOL_X86 - AS2( test DWORD PTR DATA_END, 1) - ASJ( jnz, 4, f) + AS2( test DWORD PTR K_END, 1) + ASJ( jz, 4, f) #endif AS2( movdqa xmm1, XMMWORD_PTR [AS_REG_7+1*16]) AS2( movdqa xmm0, XMMWORD_PTR [AS_REG_7+0*16]) |