Skip to content

Commit

Permalink
ascon: fix api naming Deinit -> Clear
Browse files Browse the repository at this point in the history
  • Loading branch information
julek-wolfssl committed Jan 29, 2025
1 parent c5ad780 commit ddcc189
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions doc/dox_comments/header_files/ascon.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,13 @@ int wc_AsconAEAD128_Init(wc_AsconAEAD128* a);
if (wc_AsconAEAD128_Init(&a) != 0)
// handle error
wc_AsconAEAD128_Deinit(&a);
wc_AsconAEAD128_Clear(&a);
\endcode
\sa wc_AsconAeadEncrypt
\sa wc_AsconAeadDecrypt
*/
void wc_AsconAEAD128_Deinit(wc_AsconAEAD128 *a);
void wc_AsconAEAD128_Clear(wc_AsconAEAD128 *a);

/*!
\ingroup ASCON
Expand Down Expand Up @@ -307,7 +307,7 @@ int wc_AsconAEAD128_SetAD(wc_AsconAEAD128* a, const byte* ad, word32 adSz);
\endcode
\sa wc_AsconAeadInit
\sa wc_AsconAEAD128_Deinit
\sa wc_AsconAEAD128_Clear
\sa wc_AsconAEAD128_SetKey
\sa wc_AsconAEAD128_SetNonce
\sa wc_AsconAEAD128_SetAD
Expand Down
2 changes: 1 addition & 1 deletion wolfcrypt/benchmark/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -6157,7 +6157,7 @@ void bench_ascon_aead(void)
}
if (ret == 0)
ret = wc_AsconAEAD128_EncryptFinal(enc, authTag);
wc_AsconAEAD128_Deinit(enc);
wc_AsconAEAD128_Clear(enc);

if (ret != 0) {
printf("ASCON-AEAD error: %d\n", ret);
Expand Down
14 changes: 7 additions & 7 deletions wolfcrypt/src/ascon.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ wc_AsconHash256* wc_AsconHash256_New(void)
void wc_AsconHash256_Free(wc_AsconHash256* a)
{
if (a != NULL) {
wc_AsconHash256_Deinit(a);
wc_AsconHash256_Clear(a);
XFREE(a, NULL, DYNAMIC_TYPE_ASCON);
}
}
Expand All @@ -209,7 +209,7 @@ int wc_AsconHash256_Init(wc_AsconHash256* a)
return 0;
}

void wc_AsconHash256_Deinit(wc_AsconHash256* a)
void wc_AsconHash256_Clear(wc_AsconHash256* a)
{
if (a != NULL) {
ForceZero(a, sizeof(*a));
Expand Down Expand Up @@ -271,7 +271,7 @@ int wc_AsconHash256_Final(wc_AsconHash256* a, byte* hash)
}

/* Clear state as soon as possible */
wc_AsconHash256_Deinit(a);
wc_AsconHash256_Clear(a);
return 0;
}

Expand All @@ -293,7 +293,7 @@ wc_AsconAEAD128* wc_AsconAEAD128_New(void)
void wc_AsconAEAD128_Free(wc_AsconAEAD128 *a)
{
if (a != NULL) {
wc_AsconAEAD128_Deinit(a);
wc_AsconAEAD128_Clear(a);
XFREE(a, NULL, DYNAMIC_TYPE_ASCON);
}
}
Expand All @@ -309,7 +309,7 @@ int wc_AsconAEAD128_Init(wc_AsconAEAD128 *a)
return 0;
}

void wc_AsconAEAD128_Deinit(wc_AsconAEAD128 *a)
void wc_AsconAEAD128_Clear(wc_AsconAEAD128 *a)
{
if (a != NULL) {
ForceZero(a, sizeof(*a));
Expand Down Expand Up @@ -443,7 +443,7 @@ int wc_AsconAEAD128_EncryptFinal(wc_AsconAEAD128* a, byte* tag)
XMEMCPY(tag, &a->state.s64[3], ASCON_AEAD128_TAG_SZ);

/* Clear state as soon as possible */
wc_AsconAEAD128_Deinit(a);
wc_AsconAEAD128_Clear(a);

return 0;

Expand Down Expand Up @@ -520,7 +520,7 @@ int wc_AsconAEAD128_DecryptFinal(wc_AsconAEAD128* a, const byte* tag)
return ASCON_AUTH_E;

/* Clear state as soon as possible */
wc_AsconAEAD128_Deinit(a);
wc_AsconAEAD128_Clear(a);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions wolfcrypt/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8838,7 +8838,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ascon_hash256_test(void)
return WC_TEST_RET_ENC_EC(err);
if (XMEMCMP(mdOut, ascon_hash256_output[i], ASCON_HASH256_SZ) != 0)
return WC_TEST_RET_ENC_NC;
wc_AsconHash256_Deinit(&asconHash);
wc_AsconHash256_Clear(&asconHash);
}

/* Test separated update */
Expand All @@ -8859,7 +8859,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ascon_hash256_test(void)
return WC_TEST_RET_ENC_EC(err);
if (XMEMCMP(mdOut, ascon_hash256_output[i], ASCON_HASH256_SZ) != 0)
return WC_TEST_RET_ENC_NC;
wc_AsconHash256_Deinit(&asconHash);
wc_AsconHash256_Clear(&asconHash);
}

return 0;
Expand Down Expand Up @@ -9007,7 +9007,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t ascon_aead128_test(void)
}


wc_AsconAEAD128_Deinit(&asconAEAD);
wc_AsconAEAD128_Clear(&asconAEAD);
}
}

Expand Down
4 changes: 2 additions & 2 deletions wolfssl/wolfcrypt/ascon.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ typedef struct wc_AsconAEAD128 {
WOLFSSL_API wc_AsconHash256* wc_AsconHash256_New(void);
WOLFSSL_API void wc_AsconHash256_Free(wc_AsconHash256* a);
WOLFSSL_API int wc_AsconHash256_Init(wc_AsconHash256* a);
WOLFSSL_API void wc_AsconHash256_Deinit(wc_AsconHash256* a);
WOLFSSL_API void wc_AsconHash256_Clear(wc_AsconHash256* a);
WOLFSSL_API int wc_AsconHash256_Update(wc_AsconHash256* a, const byte* data,
word32 dataSz);
WOLFSSL_API int wc_AsconHash256_Final(wc_AsconHash256* a, byte* hash);

WOLFSSL_API wc_AsconAEAD128* wc_AsconAEAD128_New(void);
WOLFSSL_API void wc_AsconAEAD128_Free(wc_AsconAEAD128* a);
WOLFSSL_API int wc_AsconAEAD128_Init(wc_AsconAEAD128* a);
WOLFSSL_API void wc_AsconAEAD128_Deinit(wc_AsconAEAD128* a);
WOLFSSL_API void wc_AsconAEAD128_Clear(wc_AsconAEAD128* a);

/* AsconAEAD API */

Expand Down

0 comments on commit ddcc189

Please sign in to comment.