avb_cmdline.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. AvbSlotVerifyData* slot_data,
  38. AvbVBMetaImageHeader* toplevel_vbmeta,
  39. AvbAlgorithmType algorithm_type,
  40. AvbHashtreeErrorMode hashtree_error_mode);
  41. /* Allocates and initializes a new command line substitution list. Free with
  42. * |avb_free_cmdline_subst_list|.
  43. */
  44. AvbCmdlineSubstList* avb_new_cmdline_subst_list(void);
  45. /* Use this instead of |avb_free| to deallocate a AvbCmdlineSubstList. */
  46. void avb_free_cmdline_subst_list(AvbCmdlineSubstList* cmdline_subst);
  47. /* Adds a hashtree root digest to be substituted in $(AVB_*_ROOT_DIGEST)
  48. * variables. The partition name differentiates the variable. For example, if
  49. * |part_name| is "foo" then $(AVB_FOO_ROOT_DIGEST) will be substituted with the
  50. * hex encoding of the digest. The substitution will be added to
  51. * |out_cmdline_subst|. Returns AVB_SLOT_VERIFY_RESULT_OK on success.
  52. */
  53. AvbSlotVerifyResult avb_add_root_digest_substitution(
  54. const char* part_name,
  55. const uint8_t* digest,
  56. size_t digest_size,
  57. AvbCmdlineSubstList* out_cmdline_subst);
  58. #endif