diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-11-28 00:46:31 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-12-07 12:36:05 +0100 |
commit | 91e0de6145402e9d1d888a6b21264668bdb85380 (patch) | |
tree | 3d6df6c1105c78eeff06638ac71ba562501fd4d8 /src | |
parent | 263abeee3a8c97e98fec49ee0ce628d6c5c5df50 (diff) | |
download | VeraCrypt-91e0de6145402e9d1d888a6b21264668bdb85380.tar.gz VeraCrypt-91e0de6145402e9d1d888a6b21264668bdb85380.zip |
Crypto: remove unnecessary alignment adjusting code in Serpent since the SIMD implementation works with unaligned data and gain negligible compared to memcpy overhead.
Diffstat (limited to 'src')
-rw-r--r-- | src/Crypto/SerpentFast.c | 48 |
1 files changed, 2 insertions, 46 deletions
diff --git a/src/Crypto/SerpentFast.c b/src/Crypto/SerpentFast.c index 02777a8f..cb143262 100644 --- a/src/Crypto/SerpentFast.c +++ b/src/Crypto/SerpentFast.c @@ -83,31 +83,9 @@ void serpent_encrypt_blocks(const unsigned __int8* in, unsigned __int8* out, siz #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE if(HasSSE2() && (blocks >= 4)) { - CRYPTOPP_ALIGN_DATA(16) unsigned __int8 alignedInputBuffer[4 * 16]; - CRYPTOPP_ALIGN_DATA(16) unsigned __int8 alignedOutputBuffer[4 * 16]; - unsigned __int8 *inPtr, *outPtr; - BOOL inputAligned = IsAligned16(in)? TRUE : FALSE; - BOOL outputAligned = IsAligned16(out)? TRUE : FALSE; - while(blocks >= 4) { - if (inputAligned) - inPtr = (unsigned __int8 *) in; - else - { - inPtr = alignedInputBuffer; - memcpy (inPtr, in, 4 * 16); - } - if (out == in) - outPtr = inPtr; - else if (outputAligned) - outPtr = (unsigned __int8 *) out; - else - { - outPtr = alignedOutputBuffer; - memcpy (outPtr, out, 4 * 16); - } - serpent_simd_encrypt_blocks_4(inPtr, outPtr, round_key); + serpent_simd_encrypt_blocks_4(in, out, round_key); in += 4 * 16; out += 4 * 16; blocks -= 4; @@ -184,31 +162,9 @@ void serpent_decrypt_blocks(const unsigned __int8* in, unsigned __int8* out, siz #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE if(HasSSE2() && (blocks >= 4)) { - CRYPTOPP_ALIGN_DATA(16) unsigned __int8 alignedInputBuffer[4 * 16]; - CRYPTOPP_ALIGN_DATA(16) unsigned __int8 alignedOutputBuffer[4 * 16]; - unsigned __int8 *inPtr, *outPtr; - BOOL inputAligned = IsAligned16(in)? TRUE : FALSE; - BOOL outputAligned = IsAligned16(out)? TRUE : FALSE; - while(blocks >= 4) { - if (inputAligned) - inPtr = (unsigned __int8 *) in; - else - { - inPtr = alignedInputBuffer; - memcpy (inPtr, in, 4 * 16); - } - if (out == in) - outPtr = inPtr; - else if (outputAligned) - outPtr = (unsigned __int8 *) out; - else - { - outPtr = alignedOutputBuffer; - memcpy (outPtr, out, 4 * 16); - } - serpent_simd_decrypt_blocks_4(inPtr, outPtr, round_key); + serpent_simd_decrypt_blocks_4(in, out, round_key); in += 4 * 16; out += 4 * 16; blocks -= 4; |