avb_footer.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright (C) 2016 The Android Open Source Project
  4. */
  5. #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION)
  6. #error "Never include this file directly, include libavb.h instead."
  7. #endif
  8. #ifndef AVB_FOOTER_H_
  9. #define AVB_FOOTER_H_
  10. #include "avb_sysdeps.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /* Magic for the footer. */
  15. #define AVB_FOOTER_MAGIC "AVBf"
  16. #define AVB_FOOTER_MAGIC_LEN 4
  17. /* Size of the footer. */
  18. #define AVB_FOOTER_SIZE 64
  19. /* The current footer version used - keep in sync with avbtool. */
  20. #define AVB_FOOTER_VERSION_MAJOR 1
  21. #define AVB_FOOTER_VERSION_MINOR 0
  22. /* The struct used as a footer used on partitions, used to find the
  23. * AvbVBMetaImageHeader struct. This struct is always stored at the
  24. * end of a partition.
  25. */
  26. typedef struct AvbFooter {
  27. /* 0: Four bytes equal to "AVBf" (AVB_FOOTER_MAGIC). */
  28. uint8_t magic[AVB_FOOTER_MAGIC_LEN];
  29. /* 4: The major version of the footer struct. */
  30. uint32_t version_major;
  31. /* 8: The minor version of the footer struct. */
  32. uint32_t version_minor;
  33. /* 12: The original size of the image on the partition. */
  34. uint64_t original_image_size;
  35. /* 20: The offset of the |AvbVBMetaImageHeader| struct. */
  36. uint64_t vbmeta_offset;
  37. /* 28: The size of the vbmeta block (header + auth + aux blocks). */
  38. uint64_t vbmeta_size;
  39. /* 36: Padding to ensure struct is size AVB_FOOTER_SIZE bytes. This
  40. * must be set to zeroes.
  41. */
  42. uint8_t reserved[28];
  43. } AVB_ATTR_PACKED AvbFooter;
  44. /* Copies |src| to |dest| and validates, byte-swapping fields in the
  45. * process if needed. Returns true if valid, false if invalid.
  46. */
  47. bool avb_footer_validate_and_byteswap(const AvbFooter* src, AvbFooter* dest)
  48. AVB_ATTR_WARN_UNUSED_RESULT;
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif /* AVB_FOOTER_H_ */