fix(mbedtls): fixing ecdsa's dependence on ecc_mult clock

This commit is contained in:
wuzhenghui 2024-02-28 14:29:22 +08:00
parent 0b920ec08a
commit 92849e660e
No known key found for this signature in database
GPG Key ID: 3EFEDECDEBA39BB9
2 changed files with 27 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: CC0-1.0
*/
@ -8,10 +8,12 @@
#include <stdbool.h>
#include <string.h>
#include "esp_crypto_lock.h"
#include "esp_efuse_chip.h"
#include "esp_private/esp_crypto_lock_internal.h"
#include "esp_random.h"
#include "hal/clk_gate_ll.h"
#include "hal/ecc_ll.h"
#include "hal/ecdsa_hal.h"
#include "hal/ecdsa_ll.h"
#include "hal/ecdsa_types.h"
@ -24,6 +26,13 @@
static void ecdsa_enable_and_reset(void)
{
esp_crypto_ecdsa_lock_acquire();
ECC_RCC_ATOMIC() {
ecc_ll_enable_bus_clock(true);
ecc_ll_reset_register();
}
ECDSA_RCC_ATOMIC() {
ecdsa_ll_enable_bus_clock(true);
ecdsa_ll_reset_register();
@ -32,9 +41,15 @@ static void ecdsa_enable_and_reset(void)
static void ecdsa_disable(void)
{
ECC_RCC_ATOMIC() {
ecc_ll_enable_bus_clock(false);
}
ECDSA_RCC_ATOMIC() {
ecdsa_ll_enable_bus_clock(false);
}
esp_crypto_ecdsa_lock_release();
}
static void ecc_be_to_le(const uint8_t* be_point, uint8_t *le_point, uint8_t len)

View File

@ -1,9 +1,10 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "hal/ecc_ll.h"
#include "hal/ecdsa_ll.h"
#include "hal/ecdsa_hal.h"
#include "esp_crypto_lock.h"
@ -25,6 +26,11 @@ static void esp_ecdsa_acquire_hardware(void)
{
esp_crypto_ecdsa_lock_acquire();
ECC_RCC_ATOMIC() {
ecc_ll_enable_bus_clock(true);
ecc_ll_reset_register();
}
ECDSA_RCC_ATOMIC() {
ecdsa_ll_enable_bus_clock(true);
ecdsa_ll_reset_register();
@ -33,6 +39,10 @@ static void esp_ecdsa_acquire_hardware(void)
static void esp_ecdsa_release_hardware(void)
{
ECC_RCC_ATOMIC() {
ecc_ll_enable_bus_clock(false);
}
ECDSA_RCC_ATOMIC() {
ecdsa_ll_enable_bus_clock(false);
}