km.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef _KM_H
  7. #define _KM_H
  8. #include "soc/soc_caps.h"
  9. #if SOC_KEY_MANAGER_SUPPORTED
  10. #include <stdint.h>
  11. #include "soc/soc.h"
  12. #include "ets_sys.h"
  13. #if __cplusplus
  14. extern "C" {
  15. #endif
  16. /* huk mode type */
  17. typedef enum {
  18. HUK_MODE_RECOVER = 0,
  19. HUK_MODE_GEN = 1,
  20. } huk_mode_t;
  21. /**
  22. * @brief Recover efuse key or key manager key if flash encryption is enabled
  23. *
  24. * @param do_log : if km process print log
  25. *
  26. * @return ETS_OK when key is recovered, ETS_FAILED when key not recovered
  27. */
  28. ETS_STATUS esp_rom_check_recover_key(int do_log);
  29. /**
  30. * @brief Configure huk mode
  31. *
  32. * @param mode : HUK_MODE_RECOVER or HUK_MODE_GEN
  33. *
  34. * @param huk_info : uint8_t pointer to the buffer which will feed the huk info or
  35. * gain the huk info
  36. *
  37. * @return ETS_OK when huk configuration is done, else ETS_FAILED
  38. */
  39. ETS_STATUS esp_rom_km_huk_conf(huk_mode_t mode, uint8_t *huk_info);
  40. /**
  41. * @brief Get huk risk. The risk level of HUK is 0-6: the higher the risk level is,
  42. * the more error bits there are in the PUF SRAM. 7: Error level, HUK is invalid
  43. *
  44. * @param None
  45. *
  46. * @return The huk risk
  47. */
  48. int esp_rom_km_huk_risk(void);
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif
  53. #endif /* _KM_H */