2 * Copyright (C) 2016 The Android Open Source Project
4 * SPDX-License-Identifier: MIT
7 #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION)
8 #error "Never include this file directly, include libavb.h instead."
11 #ifndef AVB_HASHTREE_DESCRIPTOR_H_
12 #define AVB_HASHTREE_DESCRIPTOR_H_
14 #include "avb_descriptor.h"
20 /* Flags for hashtree descriptors.
22 * AVB_HASHTREE_DESCRIPTOR_FLAGS_DO_NOT_USE_AB: Do not apply the default A/B
23 * partition logic to this partition. This is intentionally a negative boolean
24 * because A/B should be both the default and most used in practice.
27 AVB_HASHTREE_DESCRIPTOR_FLAGS_DO_NOT_USE_AB = (1 << 0),
28 } AvbHashtreeDescriptorFlags;
30 /* A descriptor containing information about a dm-verity hashtree.
32 * Hash-trees are used to verify large partitions typically containing
34 * https://gitlab.com/cryptsetup/cryptsetup/wikis/DMVerity for more
35 * information about dm-verity.
37 * Following this struct are |partition_name_len| bytes of the
38 * partition name (UTF-8 encoded), |salt_len| bytes of salt, and then
39 * |root_digest_len| bytes of the root digest.
41 * The |reserved| field is for future expansion and must be set to NUL
45 * - flags field is added which supports AVB_HASHTREE_DESCRIPTOR_FLAGS_USE_AB
46 * - digest_len may be zero, which indicates the use of a persistent digest
48 typedef struct AvbHashtreeDescriptor {
49 AvbDescriptor parent_descriptor;
50 uint32_t dm_verity_version;
54 uint32_t data_block_size;
55 uint32_t hash_block_size;
56 uint32_t fec_num_roots;
59 uint8_t hash_algorithm[32];
60 uint32_t partition_name_len;
62 uint32_t root_digest_len;
65 } AVB_ATTR_PACKED AvbHashtreeDescriptor;
67 /* Copies |src| to |dest| and validates, byte-swapping fields in the
68 * process if needed. Returns true if valid, false if invalid.
70 * Data following the struct is not validated nor copied.
72 bool avb_hashtree_descriptor_validate_and_byteswap(
73 const AvbHashtreeDescriptor* src,
74 AvbHashtreeDescriptor* dest) AVB_ATTR_WARN_UNUSED_RESULT;
80 #endif /* AVB_HASHTREE_DESCRIPTOR_H_ */