From 152f17236729f1d0b43afb6d54324e8e38549cb0 Mon Sep 17 00:00:00 2001 From: "nilesh.kale" Date: Tue, 20 Feb 2024 16:19:51 +0530 Subject: [PATCH] fix(esp_hw_support): update hmac toggle method due to discrepency in ROM code Need to update the HMAC enable/disable method due to discrepancy in ROM code across different targets for the esp_hmac_disable() API. --- components/esp_hw_support/esp_hmac.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/components/esp_hw_support/esp_hmac.c b/components/esp_hw_support/esp_hmac.c index f79899b97d..34df0aac4e 100644 --- a/components/esp_hw_support/esp_hmac.c +++ b/components/esp_hw_support/esp_hmac.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -187,7 +187,9 @@ esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token) ESP_LOGD(TAG, "HMAC computation in downstream mode is completed."); - ets_hmac_disable(); + HMAC_RCC_ATOMIC() { + hmac_ll_enable_bus_clock(false); + } esp_crypto_hmac_lock_release(); @@ -197,9 +199,17 @@ esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token) esp_err_t esp_hmac_jtag_disable() { esp_crypto_hmac_lock_acquire(); - ets_hmac_enable(); + + HMAC_RCC_ATOMIC() { + hmac_ll_enable_bus_clock(true); + } + REG_WRITE(HMAC_SET_INVALIDATE_JTAG_REG, 1); - ets_hmac_disable(); + + HMAC_RCC_ATOMIC() { + hmac_ll_enable_bus_clock(false); + } + esp_crypto_hmac_lock_release(); ESP_LOGD(TAG, "Invalidate JTAG result register. JTAG disabled."); @@ -234,7 +244,6 @@ esp_err_t esp_hmac_calculate(hmac_key_id_t key_id, } else { return ESP_OK; } - } esp_err_t esp_hmac_jtag_enable(hmac_key_id_t key_id, const uint8_t *token)