avb_footer.h 1.8 KB

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