fupdate_security.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (C) 2018 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 _FUPDATE_SECURITY_H_
  13. #define _FUPDATE_SECURITY_H_
  14. #include "fupdate.h"
  15. #include "vfs.h"
  16. #include "stdio.h"
  17. #if defined(CONFIG_SOC_8811) || defined(CONFIG_SOC_8850)
  18. #include "calclib/simage_types.h"
  19. #define FUPDATE_SIGN_MAGIC OSI_MAKE_TAG('F', 'U', 'S', '1')
  20. /**
  21. * \brief the signature file content
  22. */
  23. typedef struct
  24. {
  25. uint32_t magic; ///< magic value of the signature file
  26. uint32_t size; ///< the signature file size
  27. simageKeyCert_t sig; ///< signature content
  28. } fupdateSigHeader_t;
  29. #endif
  30. /**
  31. * \brief init the fupdate boot type after fota
  32. *
  33. * It can be called during system start.
  34. */
  35. void fupdateInitBootAfterFota(void);
  36. /**
  37. * \brief set the boot type if fota success
  38. *
  39. * It records the boot type as fota when the fota success,\p the boot type can be used after system start.
  40. *
  41. * \param result the fota result.
  42. */
  43. void fupdateSetBootAfterFota(int result);
  44. /**
  45. * \brief get the fota happened or not during bootup
  46. *
  47. * It returns whether fota happened during bootup.
  48. *
  49. * \return
  50. * - true if fota happened in bootup
  51. * - false if fota not happened
  52. */
  53. bool fupdateIsBootAfterFota(void);
  54. /**
  55. * \brief check the availble space whether enough for update the fota pack
  56. *
  57. * It returns the check result. It should be called after the fupdateCheckSignedPack() pass.
  58. *
  59. * \return
  60. * - true if the availble space enough.
  61. * - false if not.
  62. */
  63. bool fupdateIsTmpSpaceEnough(void);
  64. /**
  65. * \brief check the fota package version is upgrade or not
  66. *
  67. * It returns whether fota package upgrade to new version. \p The version info is controlled by product owner.
  68. * This interface is designed as version check sample. \p It can be modified according to the production version defination.
  69. *
  70. * \return
  71. * - true if it's upgrade or no version info in fota package.
  72. * - false if fota not to new version or failed to get the version info.
  73. */
  74. bool fupdateIsVersionUpgrade(void);
  75. // The following APIs are called in both signatue check feature is enabled and not enabled case.
  76. /**
  77. * \brief check the firmware file signature in freertos envirnment
  78. *
  79. * Check the firmware file signature. \p It will read the firmware signature and
  80. * \p the package data to check wheather signature is valid.
  81. *
  82. * If the signature check feature is not enabled,\p it will return true by default.
  83. * The package file only contains \p the firmware package data(not signed).
  84. *
  85. * \return
  86. * - true if signature check is passed
  87. * - false if not
  88. */
  89. bool fupdateCheckSignedPack(void);
  90. #endif