mbedtls: Acquire lock before enabling MPI (RSA) hardware

- For ESP32-S3
This commit is contained in:
Laukik Hase
2022-06-20 10:38:36 +05:30
parent 6c5fb29c2c
commit e114850dda

View File

@ -28,6 +28,7 @@
#include "soc/system_reg.h"
#include "soc/periph_defs.h"
#include <sys/param.h>
#include "esp_crypto_lock.h"
size_t esp_mpi_hardware_words(size_t words)
{
@ -36,6 +37,8 @@ size_t esp_mpi_hardware_words(size_t words)
void esp_mpi_enable_hardware_hw_op( void )
{
esp_crypto_mpi_lock_acquire();
/* Enable RSA hardware */
periph_module_enable(PERIPH_RSA_MODULE);
@ -54,6 +57,8 @@ void esp_mpi_disable_hardware_hw_op( void )
/* Disable RSA hardware */
periph_module_disable(PERIPH_RSA_MODULE);
esp_crypto_mpi_lock_release();
}