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