diff --git a/wolfcrypt/src/ecc.c b/wolfcrypt/src/ecc.c index f27ee2192..900b8c30c 100644 --- a/wolfcrypt/src/ecc.c +++ b/wolfcrypt/src/ecc.c @@ -9385,6 +9385,11 @@ int ecc_mul2add(ecc_point* A, mp_int* kA, return err; #ifndef HAVE_THREAD_LS + if (initMutex == 0) { /* extra sanity check if wolfCrypt_Init not called */ + wc_InitMutex(&ecc_fp_lock); + initMutex = 1; + } + if (wc_LockMutex(&ecc_fp_lock) != 0) return BAD_MUTEX_E; #endif /* HAVE_THREAD_LS */ @@ -9508,6 +9513,11 @@ int wc_ecc_mulmod_ex(mp_int* k, ecc_point *G, ecc_point *R, mp_int* a, return MP_INIT_E; #ifndef HAVE_THREAD_LS + if (initMutex == 0) { /* extra sanity check if wolfCrypt_Init not called */ + wc_InitMutex(&ecc_fp_lock); + initMutex = 1; + } + if (wc_LockMutex(&ecc_fp_lock) != 0) return BAD_MUTEX_E; #endif /* HAVE_THREAD_LS */ @@ -9627,6 +9637,11 @@ void wc_ecc_fp_free(void) { #ifndef WOLFSSL_SP_MATH #ifndef HAVE_THREAD_LS + if (initMutex == 0) { /* extra sanity check if wolfCrypt_Init not called */ + wc_InitMutex(&ecc_fp_lock); + initMutex = 1; + } + if (wc_LockMutex(&ecc_fp_lock) == 0) { #endif /* HAVE_THREAD_LS */