mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_ds: move timeout mechanism to driver layer
This commit is contained in:
parent
812d61295d
commit
7eb9ecb4f6
@ -21,9 +21,10 @@
|
||||
#include "driver/periph_ctrl.h"
|
||||
#include "esp_crypto_lock.h"
|
||||
#include "hal/ds_hal.h"
|
||||
#include "hal/ds_ll.h"
|
||||
#include "hal/hmac_hal.h"
|
||||
#include "esp32c3/rom/digital_signature.h"
|
||||
|
||||
#include "esp_timer.h"
|
||||
#include "esp_ds.h"
|
||||
|
||||
struct esp_ds_context {
|
||||
@ -128,10 +129,12 @@ esp_err_t esp_ds_start_sign(const void *message,
|
||||
ds_hal_start();
|
||||
|
||||
// check encryption key from HMAC
|
||||
ds_key_check_t key_check_result = ds_hal_check_decryption_key();
|
||||
if (key_check_result != DS_KEY_INPUT_OK) {
|
||||
ds_disable_release();
|
||||
return ESP32C3_ERR_HW_CRYPTO_DS_INVALID_KEY;
|
||||
int64_t start_time = esp_timer_get_time();
|
||||
while (ds_ll_busy() != 0) {
|
||||
if ((esp_timer_get_time() - start_time) > DS_KEY_CHECK_MAX_WAIT_US) {
|
||||
ds_disable_release();
|
||||
return ESP32C3_ERR_HW_CRYPTO_DS_INVALID_KEY;
|
||||
}
|
||||
}
|
||||
|
||||
esp_ds_context_t *context = malloc(sizeof(esp_ds_context_t));
|
||||
|
@ -26,18 +26,6 @@ void ds_hal_finish(void)
|
||||
ds_ll_finish();
|
||||
}
|
||||
|
||||
ds_key_check_t ds_hal_check_decryption_key(void)
|
||||
{
|
||||
uint64_t start_time = systimer_hal_get_time(SYSTIMER_COUNTER_0);
|
||||
while (ds_ll_busy() != 0) {
|
||||
if ((systimer_hal_get_time(SYSTIMER_COUNTER_0) - start_time) > DS_KEY_CHECK_MAX_WAIT_US) {
|
||||
return ds_ll_key_error_source();
|
||||
}
|
||||
}
|
||||
|
||||
return DS_KEY_INPUT_OK;
|
||||
}
|
||||
|
||||
void ds_hal_configure_iv(const uint32_t *iv)
|
||||
{
|
||||
ds_ll_configure_iv(iv);
|
||||
|
@ -60,11 +60,6 @@ void ds_hal_start(void);
|
||||
*/
|
||||
void ds_hal_finish(void);
|
||||
|
||||
/**
|
||||
* @brief Check whether the key input (HMAC on ESP32-C3) is correct.
|
||||
*/
|
||||
ds_key_check_t ds_hal_check_decryption_key(void);
|
||||
|
||||
/**
|
||||
* @brief Write the initialization vector.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user