Skip to content

Commit f7127ca

Browse files
committed
ascon: don't skip wc_AsconAEAD128_Clear on auth error.
1 parent b3f08f3 commit f7127ca

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

wolfcrypt/src/ascon.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,8 @@ int wc_AsconAEAD128_DecryptUpdate(wc_AsconAEAD128* a, byte* out,
491491

492492
int wc_AsconAEAD128_DecryptFinal(wc_AsconAEAD128* a, const byte* tag)
493493
{
494+
int ret = 0;
495+
494496
if (a == NULL || tag == NULL)
495497
return BAD_FUNC_ARG;
496498
if (!a->keySet || !a->nonceSet || !a->adSet)
@@ -509,13 +511,14 @@ int wc_AsconAEAD128_DecryptFinal(wc_AsconAEAD128* a, const byte* tag)
509511
a->state.s64[4] ^= a->key[1];
510512

511513
if (ConstantCompare(tag, (const byte*)&a->state.s64[3],
512-
ASCON_AEAD128_TAG_SZ) != 0)
513-
return ASCON_AUTH_E;
514+
ASCON_AEAD128_TAG_SZ) != 0) {
515+
ret = ASCON_AUTH_E;
516+
}
514517

515518
/* Clear state as soon as possible */
516519
wc_AsconAEAD128_Clear(a);
517520

518-
return 0;
521+
return ret;
519522
}
520523

521524
#endif /* HAVE_ASCON */

0 commit comments

Comments
 (0)