huk_hal.c 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. // The HAL layer for Hardware Unique Key(HUK) Generator
  7. #include "hal/huk_hal.h"
  8. #include "hal/huk_ll.h"
  9. #include "hal/huk_types.h"
  10. #include "hal/assert.h"
  11. #include "hal/log.h"
  12. #include "rom/km.h"
  13. esp_huk_state_t huk_hal_get_state(void)
  14. {
  15. return huk_ll_get_state();
  16. }
  17. static void inline huk_hal_wait_for_state(esp_huk_state_t state)
  18. {
  19. while (huk_ll_get_state() != state) {
  20. ;
  21. }
  22. }
  23. esp_err_t huk_hal_configure(const esp_huk_mode_t huk_mode, uint8_t *huk_info_buf)
  24. {
  25. if (esp_rom_km_huk_conf(huk_mode, huk_info_buf) == ETS_OK) {
  26. return ESP_OK;
  27. } else {
  28. return ESP_FAIL;
  29. }
  30. }
  31. uint8_t huk_hal_get_risk_level(void)
  32. {
  33. return (uint8_t) esp_rom_km_huk_risk();
  34. }
  35. uint32_t huk_hal_get_date_info(void)
  36. {
  37. return huk_ll_get_date_info();
  38. }