Adjusted the alignement macro to use WC_HASH_DATA_ALIGNMENT for shared settings across hash algos.

This commit is contained in:
David Garske
2019-09-26 11:53:24 -07:00
parent 6bfe6761d8
commit 78f6bbcdb8
3 changed files with 6 additions and 6 deletions

View File

@ -379,8 +379,8 @@ int wc_Md5Update(wc_Md5* md5, const byte* data, word32 len)
while (len >= WC_MD5_BLOCK_SIZE) { while (len >= WC_MD5_BLOCK_SIZE) {
/* optimization to avoid memcpy if data pointer is properly aligned */ /* optimization to avoid memcpy if data pointer is properly aligned */
/* Big Endian requires byte swap, so can't use data directly */ /* Big Endian requires byte swap, so can't use data directly */
#if defined(WC_MD5_DATA_ALIGNMENT) && !defined(BIG_ENDIAN_ORDER) #if defined(WC_HASH_DATA_ALIGNMENT) && !defined(BIG_ENDIAN_ORDER)
if (((size_t)data % WC_MD5_DATA_ALIGNMENT) == 0) { if (((size_t)data % WC_HASH_DATA_ALIGNMENT) == 0) {
local32 = (word32*)data; local32 = (word32*)data;
} }
else else

View File

@ -576,8 +576,8 @@ int wc_ShaUpdate(wc_Sha* sha, const byte* data, word32 len)
while (len >= WC_SHA_BLOCK_SIZE) { while (len >= WC_SHA_BLOCK_SIZE) {
/* optimization to avoid memcpy if data pointer is properly aligned */ /* optimization to avoid memcpy if data pointer is properly aligned */
/* Little Endian requires byte swap, so can't use data directly */ /* Little Endian requires byte swap, so can't use data directly */
#if defined(WC_SHA_DATA_ALIGNMENT) && !defined(LITTLE_ENDIAN_ORDER) #if defined(WC_HASH_DATA_ALIGNMENT) && !defined(LITTLE_ENDIAN_ORDER)
if (((size_t)data % WC_SHA_DATA_ALIGNMENT) == 0) { if (((size_t)data % WC_HASH_DATA_ALIGNMENT) == 0) {
local32 = (word32*)data; local32 = (word32*)data;
} }
else else

View File

@ -900,9 +900,9 @@ static int InitSha256(wc_Sha256* sha256)
/* optimization to avoid memcpy if data pointer is properly aligned */ /* optimization to avoid memcpy if data pointer is properly aligned */
/* Intel transform function requires use of sha256->buffer */ /* Intel transform function requires use of sha256->buffer */
/* Little Endian requires byte swap, so can't use data directly */ /* Little Endian requires byte swap, so can't use data directly */
#if defined(WC_SHA256_DATA_ALIGNMENT) && !defined(LITTLE_ENDIAN_ORDER) && \ #if defined(WC_HASH_DATA_ALIGNMENT) && !defined(LITTLE_ENDIAN_ORDER) && \
!defined(HAVE_INTEL_AVX1) && !defined(HAVE_INTEL_AVX2) !defined(HAVE_INTEL_AVX1) && !defined(HAVE_INTEL_AVX2)
if (((size_t)data % WC_SHA256_DATA_ALIGNMENT) == 0) { if (((size_t)data % WC_HASH_DATA_ALIGNMENT) == 0) {
local32 = (word32*)data; local32 = (word32*)data;
} }
else else