diff --git a/wolfcrypt/src/integer.c b/wolfcrypt/src/integer.c index 7e4bcdf65..341d99d67 100644 --- a/wolfcrypt/src/integer.c +++ b/wolfcrypt/src/integer.c @@ -169,6 +169,9 @@ int mp_init (mp_int * a) /* clear one (frees) */ void mp_clear (mp_int * a) { +#ifdef HAVE_FIPS + mp_forcezero(a); +#else int i; if (a == NULL) @@ -194,6 +197,7 @@ void mp_clear (mp_int * a) a->alloc = a->used = 0; a->sign = MP_ZPOS; } +#endif } void mp_free (mp_int * a) diff --git a/wolfcrypt/src/sp_int.c b/wolfcrypt/src/sp_int.c index 7f4d1f894..1769840e7 100644 --- a/wolfcrypt/src/sp_int.c +++ b/wolfcrypt/src/sp_int.c @@ -5268,6 +5268,9 @@ void sp_zero(sp_int* a) */ void sp_clear(sp_int* a) { +#ifdef HAVE_FIPS + sp_forcezero(a); +#else /* Clear when valid pointer passed in. */ if (a != NULL) { unsigned int i; @@ -5280,6 +5283,7 @@ void sp_clear(sp_int* a) _sp_zero(a); sp_free(a); } +#endif } #if !defined(NO_RSA) || !defined(NO_DH) || defined(HAVE_ECC) || \ diff --git a/wolfcrypt/src/tfm.c b/wolfcrypt/src/tfm.c index 04d83b5bb..5bd732860 100644 --- a/wolfcrypt/src/tfm.c +++ b/wolfcrypt/src/tfm.c @@ -4568,6 +4568,9 @@ void fp_zero(fp_int *a) void fp_clear(fp_int *a) { +#ifdef HAVE_FIPS + fp_forcezero(a); +#else int size; a->used = 0; a->sign = FP_ZPOS; @@ -4578,6 +4581,7 @@ void fp_clear(fp_int *a) #endif XMEMSET(a->dp, 0, size * sizeof(fp_digit)); fp_free(a); +#endif } void fp_forcezero (mp_int * a)