Skip to content

Commit

Permalink
Skip MQX InitMutex call if FIPS module is in Init Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lealem47 committed Jan 23, 2025
1 parent 49a74da commit 161da60
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion wolfcrypt/src/wc_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -2422,6 +2422,10 @@ int wolfSSL_HwPkMutexUnLock(void)

int wc_InitMutex(wolfSSL_Mutex* m)
{
#if (defined(HAVE_FIPS) && FIPS_VERSION_EQ(5,2))
if (wolfCrypt_GetMode_fips() == FIPS_MODE_INIT)
return 0;
#endif
if (_mutex_init(m, NULL) == MQX_EOK)
return 0;
else
Expand All @@ -2438,6 +2442,13 @@ int wolfSSL_HwPkMutexUnLock(void)

int wc_LockMutex(wolfSSL_Mutex* m)
{
#if (defined(HAVE_FIPS) && FIPS_VERSION_EQ(5,2))
if (m->VALID != MUTEX_VALID) {
if (_mutex_init(m, NULL) != MQX_EOK)
return BAD_MUTEX_E;
}
#endif

if (_mutex_lock(m) == MQX_EOK)
return 0;
else
Expand All @@ -2446,6 +2457,13 @@ int wolfSSL_HwPkMutexUnLock(void)

int wc_UnLockMutex(wolfSSL_Mutex* m)
{
#if (defined(HAVE_FIPS) && FIPS_VERSION_EQ(5,2))
if (m->VALID != MUTEX_VALID) {
if (_mutex_init(m, NULL) != MQX_EOK)
return BAD_MUTEX_E;
}
#endif

if (_mutex_unlock(m) == MQX_EOK)
return 0;
else
Expand Down Expand Up @@ -2710,7 +2728,9 @@ int wolfSSL_HwPkMutexUnLock(void)

#elif defined(WOLFSSL_CMSIS_RTOS)

#define CMSIS_NMUTEX 10
#ifndef CMSIS_NMUTEX
#define CMSIS_NMUTEX 10
#endif
osMutexDef(wolfSSL_mt0); osMutexDef(wolfSSL_mt1); osMutexDef(wolfSSL_mt2);
osMutexDef(wolfSSL_mt3); osMutexDef(wolfSSL_mt4); osMutexDef(wolfSSL_mt5);
osMutexDef(wolfSSL_mt6); osMutexDef(wolfSSL_mt7); osMutexDef(wolfSSL_mt8);
Expand Down

0 comments on commit 161da60

Please sign in to comment.