1 /* SPDX-License-Identifier: MIT */
3 * Copyright (C) 2016 The Android Open Source Project
6 #ifdef AVB_INSIDE_LIBAVB_H
7 #error "You can't include avb_sha.h in the public header libavb.h."
10 #ifndef AVB_COMPILATION
11 #error "Never include this file, it may only be used from internal avb code."
14 #ifndef AVB_CMDLINE_H_
15 #define AVB_CMDLINE_H_
18 #include "avb_slot_verify.h"
20 /* Maximum allow length (in bytes) of a partition name, including
23 #define AVB_PART_NAME_MAX_SIZE 32
25 #define AVB_MAX_NUM_CMDLINE_SUBST 10
27 /* Holds information about command-line substitutions. */
28 typedef struct AvbCmdlineSubstList {
30 char* tokens[AVB_MAX_NUM_CMDLINE_SUBST];
31 char* values[AVB_MAX_NUM_CMDLINE_SUBST];
32 } AvbCmdlineSubstList;
34 /* Substitutes all variables (e.g. $(ANDROID_SYSTEM_PARTUUID)) with
35 * values. Returns NULL on OOM, otherwise the cmdline with values
38 char* avb_sub_cmdline(AvbOps* ops,
40 const char* ab_suffix,
41 bool using_boot_for_vbmeta,
42 const AvbCmdlineSubstList* additional_substitutions);
44 AvbSlotVerifyResult avb_append_options(
46 AvbSlotVerifyData* slot_data,
47 AvbVBMetaImageHeader* toplevel_vbmeta,
48 AvbAlgorithmType algorithm_type,
49 AvbHashtreeErrorMode hashtree_error_mode);
51 /* Allocates and initializes a new command line substitution list. Free with
52 * |avb_free_cmdline_subst_list|.
54 AvbCmdlineSubstList* avb_new_cmdline_subst_list(void);
56 /* Use this instead of |avb_free| to deallocate a AvbCmdlineSubstList. */
57 void avb_free_cmdline_subst_list(AvbCmdlineSubstList* cmdline_subst);
59 /* Adds a hashtree root digest to be substituted in $(AVB_*_ROOT_DIGEST)
60 * variables. The partition name differentiates the variable. For example, if
61 * |part_name| is "foo" then $(AVB_FOO_ROOT_DIGEST) will be substituted with the
62 * hex encoding of the digest. The substitution will be added to
63 * |out_cmdline_subst|. Returns AVB_SLOT_VERIFY_RESULT_OK on success.
65 AvbSlotVerifyResult avb_add_root_digest_substitution(
66 const char* part_name,
67 const uint8_t* digest,
69 AvbCmdlineSubstList* out_cmdline_subst);