Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/portable/mbedtls/core_pkcs11_mbedtls.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@

#endif /* ifndef DISABLE_LOGGING */

/**
* @brief Global mutexes used for threading in PSA APIs. These are defined by the
* mbedtls library, we just need to initialise them.
*/
#if defined( MBEDTLS_PSA_CRYPTO_C )
extern mbedtls_threading_mutex_t mbedtls_threading_key_slot_mutex;
extern mbedtls_threading_mutex_t mbedtls_threading_psa_globaldata_mutex;
extern mbedtls_threading_mutex_t mbedtls_threading_psa_rngdata_mutex;
#endif

/**
* @ingroup pkcs11_macros
* @brief Delay to wait on acquiring a mutex, in ms.
Expand Down Expand Up @@ -475,6 +485,13 @@ static CK_RV prvMbedTLS_Initialize( void )
mbedtls_entropy_init( &xP11Context.xMbedEntropyContext );
mbedtls_ctr_drbg_init( &xP11Context.xMbedDrbgCtx );

/* Initialise the global mutexes for the PSA API's */
#if defined( MBEDTLS_PSA_CRYPTO_C )
mbedtls_mutex_init( &mbedtls_threading_key_slot_mutex );
mbedtls_mutex_init( &mbedtls_threading_psa_globaldata_mutex );
mbedtls_mutex_init( &mbedtls_threading_psa_rngdata_mutex );
#endif

lMbedTLSResult = mbedtls_ctr_drbg_seed( &xP11Context.xMbedDrbgCtx,
mbedtls_entropy_func,
&xP11Context.xMbedEntropyContext,
Expand Down