mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-29 18:27:29 +02:00
add additional FP_ECC lock sanity check for case where wolfCrypt_Init is not called
This commit is contained in:
@ -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 */
|
||||
|
||||
|
Reference in New Issue
Block a user