Skip to content

Commit e8d3e19

Browse files
committed
Address Copilot suggestions
1 parent 36acdef commit e8d3e19

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

wolfcrypt/src/port/maxim/max3266x.c

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,19 +275,34 @@ static int wc_MxcCopyCb(wc_CryptoInfo* info)
275275
switch (info->copy.type) {
276276
#ifdef MAX3266X_SHA_CB
277277
#ifndef NO_SHA
278-
case WC_HASH_TYPE_SHA: sz = sizeof(wc_Sha); break;
278+
case WC_HASH_TYPE_SHA:
279+
wc_ShaFree((wc_Sha*)info->copy.dst);
280+
sz = sizeof(wc_Sha);
281+
break;
279282
#endif
280283
#ifdef WOLFSSL_SHA224
281-
case WC_HASH_TYPE_SHA224: sz = sizeof(wc_Sha224); break;
284+
case WC_HASH_TYPE_SHA224:
285+
wc_Sha224Free((wc_Sha224*)info->copy.dst);
286+
sz = sizeof(wc_Sha224);
287+
break;
282288
#endif
283289
#ifndef NO_SHA256
284-
case WC_HASH_TYPE_SHA256: sz = sizeof(wc_Sha256); break;
290+
case WC_HASH_TYPE_SHA256:
291+
wc_Sha256Free((wc_Sha256*)info->copy.dst);
292+
sz = sizeof(wc_Sha256);
293+
break;
285294
#endif
286295
#ifdef WOLFSSL_SHA384
287-
case WC_HASH_TYPE_SHA384: sz = sizeof(wc_Sha384); break;
296+
case WC_HASH_TYPE_SHA384:
297+
wc_Sha384Free((wc_Sha384*)info->copy.dst);
298+
sz = sizeof(wc_Sha384);
299+
break;
288300
#endif
289301
#ifdef WOLFSSL_SHA512
290-
case WC_HASH_TYPE_SHA512: sz = sizeof(wc_Sha512); break;
302+
case WC_HASH_TYPE_SHA512:
303+
wc_Sha512Free((wc_Sha512*)info->copy.dst);
304+
sz = sizeof(wc_Sha512);
305+
break;
291306
#endif
292307
#endif /* MAX3266X_SHA_CB */
293308
default:
@@ -657,7 +672,7 @@ int wc_MxcCb_AesCbcDecrypt(Aes* aes, byte* out, const byte* in, word32 sz)
657672
/* TPU hash helpers (bare-metal SHA accelerator) */
658673

659674
/* Reset TPU, select hash function, and restore intermediate state into
660-
* the HASH_DIGEST registers. Does NOT set INIT - caller provides state. */
675+
* the HASH_DIGEST registers. */
661676
void wc_MXC_TPU_Hash_Setup(MXC_TPU_HASH_TYPE algo,
662677
const unsigned int* state, int stateWords)
663678
{

0 commit comments

Comments
 (0)