mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-18 10:31:09 +00:00
Merge branch 'fix/crypto_periphs_use_rcc_atomic_blocks' into 'master'
Use rcc atomic blocks to enable/reset crypto peripherals See merge request espressif/esp-idf!25811
This commit is contained in:
@@ -4,19 +4,22 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "esp_crypto_lock.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "bignum_impl.h"
|
||||
#include "mbedtls/bignum.h"
|
||||
#include "esp_private/esp_crypto_lock_internal.h"
|
||||
|
||||
#include "hal/mpi_hal.h"
|
||||
|
||||
#include "hal/mpi_ll.h"
|
||||
|
||||
void esp_mpi_enable_hardware_hw_op( void )
|
||||
{
|
||||
esp_crypto_mpi_lock_acquire();
|
||||
|
||||
/* Enable RSA hardware */
|
||||
periph_module_enable(PERIPH_RSA_MODULE);
|
||||
MPI_RCC_ATOMIC() {
|
||||
mpi_ll_enable_bus_clock(true);
|
||||
mpi_ll_reset_register();
|
||||
}
|
||||
|
||||
mpi_hal_enable_hardware_hw_op();
|
||||
}
|
||||
@@ -27,7 +30,9 @@ void esp_mpi_disable_hardware_hw_op( void )
|
||||
mpi_hal_disable_hardware_hw_op();
|
||||
|
||||
/* Disable RSA hardware */
|
||||
periph_module_disable(PERIPH_RSA_MODULE);
|
||||
MPI_RCC_ATOMIC() {
|
||||
mpi_ll_enable_bus_clock(false);
|
||||
}
|
||||
|
||||
esp_crypto_mpi_lock_release();
|
||||
}
|
||||
|
||||
@@ -8,20 +8,26 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "esp_crypto_lock.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "esp_private/esp_crypto_lock_internal.h"
|
||||
#include "ecc_impl.h"
|
||||
#include "hal/ecc_hal.h"
|
||||
#include "hal/ecc_ll.h"
|
||||
|
||||
static void esp_ecc_acquire_hardware(void)
|
||||
{
|
||||
esp_crypto_ecc_lock_acquire();
|
||||
|
||||
periph_module_enable(PERIPH_ECC_MODULE);
|
||||
ECC_RCC_ATOMIC() {
|
||||
ecc_ll_enable_bus_clock(true);
|
||||
ecc_ll_reset_register();
|
||||
}
|
||||
}
|
||||
|
||||
static void esp_ecc_release_hardware(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_ECC_MODULE);
|
||||
ECC_RCC_ATOMIC() {
|
||||
ecc_ll_enable_bus_clock(false);
|
||||
}
|
||||
|
||||
esp_crypto_ecc_lock_release();
|
||||
}
|
||||
|
||||
@@ -4,14 +4,15 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <string.h>
|
||||
#include "hal/ecdsa_ll.h"
|
||||
#include "hal/ecdsa_hal.h"
|
||||
#include "esp_crypto_lock.h"
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_private/esp_crypto_lock_internal.h"
|
||||
#include "mbedtls/error.h"
|
||||
#include "mbedtls/ecdsa.h"
|
||||
#include "mbedtls/asn1write.h"
|
||||
#include "mbedtls/platform_util.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
#include "ecdsa/ecdsa_alt.h"
|
||||
|
||||
#define ECDSA_KEY_MAGIC (short) 0xECD5A
|
||||
@@ -24,12 +25,17 @@ static void esp_ecdsa_acquire_hardware(void)
|
||||
{
|
||||
esp_crypto_ecdsa_lock_acquire();
|
||||
|
||||
periph_module_enable(PERIPH_ECDSA_MODULE);
|
||||
ECDSA_RCC_ATOMIC() {
|
||||
ecdsa_ll_enable_bus_clock(true);
|
||||
ecdsa_ll_reset_register();
|
||||
}
|
||||
}
|
||||
|
||||
static void esp_ecdsa_release_hardware(void)
|
||||
{
|
||||
periph_module_disable(PERIPH_ECDSA_MODULE);
|
||||
ECDSA_RCC_ATOMIC() {
|
||||
ecdsa_ll_enable_bus_clock(false);
|
||||
}
|
||||
|
||||
esp_crypto_ecdsa_lock_release();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user