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