2023-10-12 10:47:52 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
// The HAL layer for Hardware Unique Key(HUK) Generator
|
|
|
|
|
|
|
|
|
|
|
|
#include "hal/huk_hal.h"
|
|
|
|
#include "hal/huk_ll.h"
|
|
|
|
#include "hal/huk_types.h"
|
|
|
|
#include "hal/assert.h"
|
|
|
|
#include "hal/log.h"
|
|
|
|
#include "rom/km.h"
|
2023-10-12 11:25:40 +00:00
|
|
|
#include "esp_err.h"
|
2023-10-12 10:47:52 +00:00
|
|
|
|
|
|
|
esp_huk_state_t huk_hal_get_state(void)
|
|
|
|
{
|
|
|
|
return huk_ll_get_state();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void inline huk_hal_wait_for_state(esp_huk_state_t state)
|
|
|
|
{
|
|
|
|
while (huk_ll_get_state() != state) {
|
|
|
|
;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-12 10:48:58 +00:00
|
|
|
esp_err_t huk_hal_configure(const esp_huk_mode_t huk_mode, uint8_t *huk_info_buf)
|
2023-10-12 10:47:52 +00:00
|
|
|
{
|
2023-10-12 10:48:58 +00:00
|
|
|
if (esp_rom_km_huk_conf(huk_mode, huk_info_buf) == ETS_OK) {
|
|
|
|
return ESP_OK;
|
|
|
|
} else {
|
|
|
|
return ESP_FAIL;
|
|
|
|
}
|
2023-10-12 10:47:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t huk_hal_get_risk_level(void)
|
|
|
|
{
|
|
|
|
return (uint8_t) esp_rom_km_huk_risk();
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t huk_hal_get_date_info(void)
|
|
|
|
{
|
|
|
|
return huk_ll_get_date_info();
|
|
|
|
}
|