@@ -806,7 +806,7 @@ static int Sha3Final(wc_Sha3* sha3, byte padChar, byte* hash, byte p, word32 l)
806806 * devId Device identifier for asynchronous operation.
807807 * returns 0 on success.
808808 */
809- static int wc_InitSha3 (wc_Sha3 * sha3 , int type , void * heap , int devId )
809+ static int wc_InitSha3 (wc_Sha3 * sha3 , void * heap , int devId )
810810{
811811 int ret = 0 ;
812812
@@ -823,12 +823,9 @@ static int wc_InitSha3(wc_Sha3* sha3, int type, void* heap, int devId)
823823 WOLFSSL_ASYNC_MARKER_SHA3 , sha3 -> heap , devId );
824824#elif defined(WOLF_CRYPTO_CB )
825825 sha3 -> devId = devId ;
826- sha3 -> type = type ;
827-
828826#endif /* WOLFSSL_ASYNC_CRYPT */
829827
830828 (void )devId ;
831- (void )type ;
832829
833830 return ret ;
834831}
@@ -859,7 +856,15 @@ static int wc_Sha3Update(wc_Sha3* sha3, const byte* data, word32 len, byte p)
859856 if (sha3 -> devId != INVALID_DEVID )
860857 #endif
861858 {
862- ret = wc_CryptoCb_Sha3Hash (sha3 , sha3 -> type , data , len , NULL );
859+ int hash_type = WC_HASH_TYPE_NONE ;
860+ switch (p ) {
861+ case WC_SHA3_224_COUNT : hash_type = WC_HASH_TYPE_SHA3_224 ; break ;
862+ case WC_SHA3_256_COUNT : hash_type = WC_HASH_TYPE_SHA3_256 ; break ;
863+ case WC_SHA3_384_COUNT : hash_type = WC_HASH_TYPE_SHA3_384 ; break ;
864+ case WC_SHA3_512_COUNT : hash_type = WC_HASH_TYPE_SHA3_512 ; break ;
865+ default : return BAD_FUNC_ARG ;
866+ }
867+ ret = wc_CryptoCb_Sha3Hash (sha3 , hash_type , data , len , NULL );
863868 if (ret != WC_NO_ERR_TRACE (CRYPTOCB_UNAVAILABLE ))
864869 return ret ;
865870 /* fall-through when unavailable */
@@ -905,7 +910,15 @@ static int wc_Sha3Final(wc_Sha3* sha3, byte* hash, byte p, byte len)
905910 if (sha3 -> devId != INVALID_DEVID )
906911 #endif
907912 {
908- ret = wc_CryptoCb_Sha3Hash (sha3 , sha3 -> type , NULL , 0 , hash );
913+ int hash_type = WC_HASH_TYPE_NONE ;
914+ switch (p ) {
915+ case WC_SHA3_224_COUNT : hash_type = WC_HASH_TYPE_SHA3_224 ; break ;
916+ case WC_SHA3_256_COUNT : hash_type = WC_HASH_TYPE_SHA3_256 ; break ;
917+ case WC_SHA3_384_COUNT : hash_type = WC_HASH_TYPE_SHA3_384 ; break ;
918+ case WC_SHA3_512_COUNT : hash_type = WC_HASH_TYPE_SHA3_512 ; break ;
919+ default : return BAD_FUNC_ARG ;
920+ }
921+ ret = wc_CryptoCb_Sha3Hash (sha3 , hash_type , NULL , 0 , hash );
909922 if (ret != WC_NO_ERR_TRACE (CRYPTOCB_UNAVAILABLE ))
910923 return ret ;
911924 /* fall-through when unavailable */
@@ -1012,7 +1025,7 @@ static int wc_Sha3GetHash(wc_Sha3* sha3, byte* hash, byte p, byte len)
10121025 */
10131026int wc_InitSha3_224 (wc_Sha3 * sha3 , void * heap , int devId )
10141027{
1015- return wc_InitSha3 (sha3 , WC_HASH_TYPE_SHA3_224 , heap , devId );
1028+ return wc_InitSha3 (sha3 , heap , devId );
10161029}
10171030
10181031/* Update the SHA3-224 hash state with message data.
@@ -1084,7 +1097,7 @@ int wc_Sha3_224_Copy(wc_Sha3* src, wc_Sha3* dst)
10841097 */
10851098int wc_InitSha3_256 (wc_Sha3 * sha3 , void * heap , int devId )
10861099{
1087- return wc_InitSha3 (sha3 , WC_HASH_TYPE_SHA3_256 , heap , devId );
1100+ return wc_InitSha3 (sha3 , heap , devId );
10881101}
10891102
10901103/* Update the SHA3-256 hash state with message data.
@@ -1156,7 +1169,7 @@ int wc_Sha3_256_Copy(wc_Sha3* src, wc_Sha3* dst)
11561169 */
11571170int wc_InitSha3_384 (wc_Sha3 * sha3 , void * heap , int devId )
11581171{
1159- return wc_InitSha3 (sha3 , WC_HASH_TYPE_SHA3_384 , heap , devId );
1172+ return wc_InitSha3 (sha3 , heap , devId );
11601173}
11611174
11621175/* Update the SHA3-384 hash state with message data.
@@ -1228,7 +1241,7 @@ int wc_Sha3_384_Copy(wc_Sha3* src, wc_Sha3* dst)
12281241 */
12291242int wc_InitSha3_512 (wc_Sha3 * sha3 , void * heap , int devId )
12301243{
1231- return wc_InitSha3 (sha3 , WC_HASH_TYPE_SHA3_512 , heap , devId );
1244+ return wc_InitSha3 (sha3 , heap , devId );
12321245}
12331246
12341247/* Update the SHA3-512 hash state with message data.
@@ -1317,7 +1330,7 @@ int wc_Sha3_GetFlags(wc_Sha3* sha3, word32* flags)
13171330 */
13181331int wc_InitShake128 (wc_Shake * shake , void * heap , int devId )
13191332{
1320- return wc_InitSha3 (shake , WC_HASH_TYPE_SHAKE128 , heap , devId );
1333+ return wc_InitSha3 (shake , heap , devId );
13211334}
13221335
13231336/* Update the SHAKE128 hash state with message data.
@@ -1461,7 +1474,7 @@ int wc_Shake128_Copy(wc_Shake* src, wc_Shake* dst)
14611474 */
14621475int wc_InitShake256 (wc_Shake * shake , void * heap , int devId )
14631476{
1464- return wc_InitSha3 (shake , WC_HASH_TYPE_SHAKE256 , heap , devId );
1477+ return wc_InitSha3 (shake , heap , devId );
14651478}
14661479
14671480/* Update the SHAKE256 hash state with message data.
0 commit comments