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