Skip to content

Commit 8c0ef0b

Browse files
committed
Explicit API redirects for FIPS moving forward
1 parent 0e27b3e commit 8c0ef0b

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

wolfcrypt/src/integer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ int mp_init (mp_int * a)
177177
/* clear one (frees) */
178178
void mp_clear (mp_int * a)
179179
{
180+
#ifdef HAVE_FIPS
181+
mp_forcezero(a);
182+
#else
180183
int i;
181184

182185
if (a == NULL)
@@ -202,6 +205,7 @@ void mp_clear (mp_int * a)
202205
a->alloc = a->used = 0;
203206
a->sign = MP_ZPOS;
204207
}
208+
#endif
205209
}
206210

207211
void mp_free (mp_int * a)

wolfcrypt/src/sp_int.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5272,6 +5272,9 @@ void sp_zero(sp_int* a)
52725272
*/
52735273
void sp_clear(sp_int* a)
52745274
{
5275+
#ifdef HAVE_FIPS
5276+
sp_forcezero(a);
5277+
#else
52755278
/* Clear when valid pointer passed in. */
52765279
if (a != NULL) {
52775280
unsigned int i;
@@ -5284,6 +5287,7 @@ void sp_clear(sp_int* a)
52845287
_sp_zero(a);
52855288
sp_free(a);
52865289
}
5290+
#endif
52875291
}
52885292

52895293
#if !defined(NO_RSA) || !defined(NO_DH) || defined(HAVE_ECC) || \

wolfcrypt/src/tfm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4575,6 +4575,9 @@ void fp_zero(fp_int *a)
45754575

45764576
void fp_clear(fp_int *a)
45774577
{
4578+
#ifdef HAVE_FIPS
4579+
fp_forcezero(a);
4580+
#else
45784581
int size;
45794582
a->used = 0;
45804583
a->sign = FP_ZPOS;
@@ -4585,6 +4588,7 @@ void fp_clear(fp_int *a)
45854588
#endif
45864589
XMEMSET(a->dp, 0, size * sizeof(fp_digit));
45874590
fp_free(a);
4591+
#endif
45884592
}
45894593

45904594
void fp_forcezero (mp_int * a)

0 commit comments

Comments
 (0)