avb_cmdline.h 2.2 KB

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