mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 02:37:28 +02:00
Fix for SHA256 missing initialization of small stack cache variable. Fixes issue with Intel ASM and WOLFSSL_SMALL_STACK_CACHE
This commit is contained in:
@ -369,6 +369,9 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
#ifdef WOLF_CRYPTO_CB
|
||||
sha256->devId = devId;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha256->W = NULL;
|
||||
#endif
|
||||
|
||||
ret = InitSha256(sha256);
|
||||
if (ret != 0)
|
||||
@ -697,15 +700,14 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
sha256->devId = devId;
|
||||
sha256->devCtx = NULL;
|
||||
#endif
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha256->W = NULL;
|
||||
#endif
|
||||
|
||||
ret = InitSha256(sha256);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha256->W = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA256)
|
||||
ret = wolfAsync_DevCtxInit(&sha256->asyncDev,
|
||||
WOLFSSL_ASYNC_MARKER_SHA256, sha256->heap, devId);
|
||||
@ -1264,6 +1266,7 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
(void)devId;
|
||||
(void)heap;
|
||||
|
||||
XMEMSET(sha224, 0, sizeof(wc_Sha224));
|
||||
wc_Stm32_Hash_Init(&sha224->stmCtx);
|
||||
return 0;
|
||||
}
|
||||
@ -1362,15 +1365,14 @@ static int InitSha256(wc_Sha256* sha256)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
sha224->heap = heap;
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha224->W = NULL;
|
||||
#endif
|
||||
|
||||
ret = InitSha224(sha224);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha224->W = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA224)
|
||||
ret = wolfAsync_DevCtxInit(&sha224->asyncDev,
|
||||
WOLFSSL_ASYNC_MARKER_SHA224, sha224->heap, devId);
|
||||
|
@ -398,6 +398,9 @@ int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
sha512->heap = heap;
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha512->W = NULL;
|
||||
#endif
|
||||
|
||||
ret = InitSha512(sha512);
|
||||
if (ret != 0)
|
||||
@ -407,10 +410,6 @@ int wc_InitSha512_ex(wc_Sha512* sha512, void* heap, int devId)
|
||||
Sha512_SetTransform();
|
||||
#endif
|
||||
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha512->W = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA512)
|
||||
ret = wolfAsync_DevCtxInit(&sha512->asyncDev,
|
||||
WOLFSSL_ASYNC_MARKER_SHA512, sha512->heap, devId);
|
||||
@ -507,8 +506,7 @@ static int _Transform_Sha512(wc_Sha512* sha512)
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
word64* W = sha512->W;
|
||||
if (W == NULL) {
|
||||
W = (word64*) XMALLOC(sizeof(word64) * 16, NULL,
|
||||
DYNAMIC_TYPE_TMP_BUFFER);
|
||||
W = (word64*)XMALLOC(sizeof(word64) * 16, NULL,DYNAMIC_TYPE_TMP_BUFFER);
|
||||
if (W == NULL)
|
||||
return MEMORY_E;
|
||||
sha512->W = W;
|
||||
@ -1019,6 +1017,10 @@ int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
|
||||
}
|
||||
|
||||
sha384->heap = heap;
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha384->W = NULL;
|
||||
#endif
|
||||
|
||||
ret = InitSha384(sha384);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
@ -1026,9 +1028,6 @@ int wc_InitSha384_ex(wc_Sha384* sha384, void* heap, int devId)
|
||||
#if defined(HAVE_INTEL_AVX1) || defined(HAVE_INTEL_AVX2)
|
||||
Sha512_SetTransform();
|
||||
#endif
|
||||
#ifdef WOLFSSL_SMALL_STACK_CACHE
|
||||
sha384->W = NULL;
|
||||
#endif
|
||||
|
||||
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_SHA384)
|
||||
ret = wolfAsync_DevCtxInit(&sha384->asyncDev, WOLFSSL_ASYNC_MARKER_SHA384,
|
||||
|
Reference in New Issue
Block a user