gate access to wc_Sha512.devId on !NO_SHA2_CRYPTO_CB.

This commit is contained in:
Daniel Pouzzner
2021-10-08 18:41:27 -05:00
parent 5d796ba06c
commit c0778e5ad9
2 changed files with 16 additions and 2 deletions

View File

@ -785,10 +785,13 @@ int wc_CryptoCb_Sha384Hash(wc_Sha384* sha384, const byte* in,
CryptoCb* dev; CryptoCb* dev;
/* locate registered callback */ /* locate registered callback */
#ifndef NO_SHA2_CRYPTO_CB
if (sha384) { if (sha384) {
dev = wc_CryptoCb_FindDevice(sha384->devId); dev = wc_CryptoCb_FindDevice(sha384->devId);
} }
else { else
#endif
{
/* locate first callback and try using it */ /* locate first callback and try using it */
dev = wc_CryptoCb_FindDeviceByIndex(0); dev = wc_CryptoCb_FindDeviceByIndex(0);
} }
@ -818,10 +821,13 @@ int wc_CryptoCb_Sha512Hash(wc_Sha512* sha512, const byte* in,
CryptoCb* dev; CryptoCb* dev;
/* locate registered callback */ /* locate registered callback */
#ifndef NO_SHA2_CRYPTO_CB
if (sha512) { if (sha512) {
dev = wc_CryptoCb_FindDevice(sha512->devId); dev = wc_CryptoCb_FindDevice(sha512->devId);
} }
else { else
#endif
{
/* locate first callback and try using it */ /* locate first callback and try using it */
dev = wc_CryptoCb_FindDeviceByIndex(0); dev = wc_CryptoCb_FindDeviceByIndex(0);
} }

View File

@ -38075,8 +38075,10 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
if (info->hash.sha384 == NULL) if (info->hash.sha384 == NULL)
return NOT_COMPILED_IN; return NOT_COMPILED_IN;
#ifndef NO_SHA2_CRYPTO_CB
/* set devId to invalid, so software is used */ /* set devId to invalid, so software is used */
info->hash.sha384->devId = INVALID_DEVID; info->hash.sha384->devId = INVALID_DEVID;
#endif
if (info->hash.in != NULL) { if (info->hash.in != NULL) {
ret = wc_Sha384Update( ret = wc_Sha384Update(
@ -38090,8 +38092,10 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
info->hash.digest); info->hash.digest);
} }
#ifndef NO_SHA2_CRYPTO_CB
/* reset devId */ /* reset devId */
info->hash.sha384->devId = devIdArg; info->hash.sha384->devId = devIdArg;
#endif
} }
else else
#endif #endif
@ -38100,8 +38104,10 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
if (info->hash.sha512 == NULL) if (info->hash.sha512 == NULL)
return NOT_COMPILED_IN; return NOT_COMPILED_IN;
#ifndef NO_SHA2_CRYPTO_CB
/* set devId to invalid, so software is used */ /* set devId to invalid, so software is used */
info->hash.sha512->devId = INVALID_DEVID; info->hash.sha512->devId = INVALID_DEVID;
#endif
if (info->hash.in != NULL) { if (info->hash.in != NULL) {
ret = wc_Sha512Update( ret = wc_Sha512Update(
@ -38115,8 +38121,10 @@ static int myCryptoDevCb(int devIdArg, wc_CryptoInfo* info, void* ctx)
info->hash.digest); info->hash.digest);
} }
#ifndef NO_SHA2_CRYPTO_CB
/* reset devId */ /* reset devId */
info->hash.sha512->devId = devIdArg; info->hash.sha512->devId = devIdArg;
#endif
} }
else else
#endif #endif