mbedtls icon indicating copy to clipboard operation
mbedtls copied to clipboard

Add a global mutex for global data

Open yanesca opened this issue 1 year ago • 2 comments

See the design document for background and this thread for justification.

Add a new global mutex and make sure that every function accessing or modifying the global_data static variable in psa_crypto.c takes that mutex. The functions should take the mutex in a way that the consistency of the whole structure is guaranteed. ~The mutex should protect the PSA Crypto random generator as well.~

The task is complete when the above described mutex and protection is added along with multi-threaded unit tests.

yanesca avatar Oct 26 '23 09:10 yanesca

It makes sense to handle MBEDTLS_PSA_CRYPTO_EXTERNAL_RNG consistently with drivers. In the MVP thread safety is the responsibility of the drivers and the core does not make any guarantees.

yanesca avatar Dec 29 '23 11:12 yanesca

During the review of https://github.com/Mbed-TLS/mbedtls/pull/8744 I realised that we have forgotten about the psa_crypto_transaction global variable. It should be protected by a mutex as well, question is which one. The keystore mutex seems convenient, but might not work or might not be very efficient in all cases.

yanesca avatar Feb 15 '24 16:02 yanesca