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