Fix typo in code comment for ECC curve cache. Fix for valgrind report of possible use of uninitialized value with ChaCha/Poly AEAD test.

This commit is contained in:
David Garske
2020-08-27 12:01:24 -07:00
parent 32b46e344d
commit 21d17b17d0
2 changed files with 8 additions and 3 deletions

View File

@ -1305,7 +1305,7 @@ static void wc_ecc_curve_free(ecc_curve_spec* curve)
if (curve) { if (curve) {
#ifdef ECC_CACHE_CURVE #ifdef ECC_CACHE_CURVE
#ifdef WOLFSSL_CUSTOM_CURVES #ifdef WOLFSSL_CUSTOM_CURVES
/* only free custom curves (reset are globally cached) */ /* only free custom curves (rest are globally cached) */
if (curve->dp && curve->dp->id == ECC_CURVE_CUSTOM) { if (curve->dp && curve->dp->id == ECC_CURVE_CUSTOM) {
wc_ecc_curve_cache_free_spec(curve); wc_ecc_curve_cache_free_spec(curve);
XFREE(curve, NULL, DYNAMIC_TYPE_ECC); XFREE(curve, NULL, DYNAMIC_TYPE_ECC);

View File

@ -5336,7 +5336,7 @@ int chacha20_poly1305_aead_test(void)
} }
/* AEAD init/update/final */ /* AEAD init/update/final - bad argument tests */
err = wc_ChaCha20Poly1305_Init(NULL, key1, iv1, err = wc_ChaCha20Poly1305_Init(NULL, key1, iv1,
CHACHA20_POLY1305_AEAD_DECRYPT); CHACHA20_POLY1305_AEAD_DECRYPT);
if (err != BAD_FUNC_ARG) if (err != BAD_FUNC_ARG)
@ -5374,7 +5374,12 @@ int chacha20_poly1305_aead_test(void)
if (err != BAD_FUNC_ARG) if (err != BAD_FUNC_ARG)
return -4727; return -4727;
/* AEAD init/update/final - state tests */ /* AEAD init/update/final - bad state tests */
/* clear struct - make valgrind happy to resolve
"Conditional jump or move depends on uninitialised value(s)".
The enum is "int" size and aead.state is "byte" */
/* The wc_ChaCha20Poly1305_Init function does this normally */
XMEMSET(&aead, 0, sizeof(aead));
aead.state = CHACHA20_POLY1305_STATE_INIT; aead.state = CHACHA20_POLY1305_STATE_INIT;
err = wc_ChaCha20Poly1305_UpdateAad(&aead, aad1, sizeof(aad1)); err = wc_ChaCha20Poly1305_UpdateAad(&aead, aad1, sizeof(aad1));
if (err != BAD_STATE_E) if (err != BAD_STATE_E)