boot_secure.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Copyright (C) 2017 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _BOOT_SECURE_H_
  13. #define _BOOT_SECURE_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #include "osi_compiler.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. struct simageHeader;
  22. /**
  23. * @brief Get Efuse Content of secure boot.
  24. */
  25. void bootGetEfuseCtx(void);
  26. /**
  27. * @brief Check secure boot state.
  28. *
  29. * @return
  30. * - false secure boot disable .
  31. * - true secure boot enable.
  32. */
  33. bool bootSecureBootEnable(void);
  34. /**
  35. * @brief Check the uimage signature (8910).
  36. *
  37. * For compatible, when secure boot is not enabled, it will return true
  38. * directly.
  39. *
  40. * @param header Input the address of the uimage header.
  41. * @return
  42. * - true for signature check pass.
  43. * - false for signature check fail.
  44. */
  45. bool bootSecureUimageSigCheck(const void *header);
  46. /**
  47. * @brief Check data signature (8910).
  48. *
  49. * It is assumed that the signature is at the end of data.
  50. *
  51. * For compatible, when secure boot is not enabled, it will return true
  52. * directly.
  53. *
  54. * @param buf Input the address of the signed data.
  55. * @param len Input the length of the signed data.
  56. * @return
  57. * - true for signature check pass.
  58. * - false for signature check fail.
  59. */
  60. bool bootSecureEmbeddedSigCheck(const void *buf, uint32_t len);
  61. /**
  62. * @brief Encrypt the data using aes algorithm in place (8910).
  63. *
  64. * It won't check whether secure boot is enabled. It is suggested to
  65. * call this only when secure boot is enabled.
  66. *
  67. * @param buf Input the address of the data.
  68. * @param len Input the length of the data.
  69. */
  70. void bootAntiCloneEncryption(void *buf, uint32_t len);
  71. /**
  72. * @brief Check the simage signature.
  73. *
  74. * @header Input the address of the simage header.
  75. * @return
  76. * - 0 verify ok.
  77. * - nonzero verify fail.
  78. */
  79. bool bootSimageCheckSign(const struct simageHeader *header);
  80. #ifdef CONFIG_QUEC_PROJECT_FEATURE
  81. void bootGetEfuseCtx(void);
  82. #endif
  83. #ifdef __cplusplus
  84. }
  85. #endif
  86. #endif