avb_cmdline.h 2.3 KB

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