avb_cmdline.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2016 The Android Open Source Project
  3. *
  4. * Permission is hereby granted, free of charge, to any person
  5. * obtaining a copy of this software and associated documentation
  6. * files (the "Software"), to deal in the Software without
  7. * restriction, including without limitation the rights to use, copy,
  8. * modify, merge, publish, distribute, sublicense, and/or sell copies
  9. * of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be
  13. * included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  19. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  20. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  21. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. #ifdef AVB_INSIDE_LIBAVB_H
  25. #error "You can't include avb_sha.h in the public header libavb.h."
  26. #endif
  27. #ifndef AVB_COMPILATION
  28. #error "Never include this file, it may only be used from internal avb code."
  29. #endif
  30. #ifndef AVB_CMDLINE_H_
  31. #define AVB_CMDLINE_H_
  32. #include "avb_ops.h"
  33. #include "avb_slot_verify.h"
  34. /* Maximum allow length (in bytes) of a partition name, including
  35. * ab_suffix.
  36. */
  37. #define AVB_PART_NAME_MAX_SIZE 32
  38. #define AVB_MAX_NUM_CMDLINE_SUBST 10
  39. /* Holds information about command-line substitutions. */
  40. typedef struct AvbCmdlineSubstList {
  41. size_t size;
  42. char* tokens[AVB_MAX_NUM_CMDLINE_SUBST];
  43. char* values[AVB_MAX_NUM_CMDLINE_SUBST];
  44. } AvbCmdlineSubstList;
  45. /* Substitutes all variables (e.g. $(ANDROID_SYSTEM_PARTUUID)) with
  46. * values. Returns NULL on OOM, otherwise the cmdline with values
  47. * replaced.
  48. */
  49. char* avb_sub_cmdline(AvbOps* ops,
  50. const char* cmdline,
  51. const char* ab_suffix,
  52. bool using_boot_for_vbmeta,
  53. const AvbCmdlineSubstList* additional_substitutions);
  54. AvbSlotVerifyResult avb_append_options(
  55. AvbOps* ops,
  56. AvbSlotVerifyData* slot_data,
  57. AvbVBMetaImageHeader* toplevel_vbmeta,
  58. AvbAlgorithmType algorithm_type,
  59. AvbHashtreeErrorMode hashtree_error_mode,
  60. AvbHashtreeErrorMode resolved_hashtree_error_mode);
  61. /* Allocates and initializes a new command line substitution list. Free with
  62. * |avb_free_cmdline_subst_list|.
  63. */
  64. AvbCmdlineSubstList* avb_new_cmdline_subst_list(void);
  65. /* Use this instead of |avb_free| to deallocate a AvbCmdlineSubstList. */
  66. void avb_free_cmdline_subst_list(AvbCmdlineSubstList* cmdline_subst);
  67. /* Adds a hashtree root digest to be substituted in $(AVB_*_ROOT_DIGEST)
  68. * variables. The partition name differentiates the variable. For example, if
  69. * |part_name| is "foo" then $(AVB_FOO_ROOT_DIGEST) will be substituted with the
  70. * hex encoding of the digest. The substitution will be added to
  71. * |out_cmdline_subst|. Returns AVB_SLOT_VERIFY_RESULT_OK on success.
  72. */
  73. AvbSlotVerifyResult avb_add_root_digest_substitution(
  74. const char* part_name,
  75. const uint8_t* digest,
  76. size_t digest_size,
  77. AvbCmdlineSubstList* out_cmdline_subst);
  78. #endif