avb_cmdline.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. AvbSlotVerifyFlags flags,
  57. AvbSlotVerifyData* slot_data,
  58. AvbVBMetaImageHeader* toplevel_vbmeta,
  59. AvbAlgorithmType algorithm_type,
  60. AvbHashtreeErrorMode hashtree_error_mode,
  61. AvbHashtreeErrorMode resolved_hashtree_error_mode);
  62. /* Allocates and initializes a new command line substitution list. Free with
  63. * |avb_free_cmdline_subst_list|.
  64. */
  65. AvbCmdlineSubstList* avb_new_cmdline_subst_list(void);
  66. /* Use this instead of |avb_free| to deallocate a AvbCmdlineSubstList. */
  67. void avb_free_cmdline_subst_list(AvbCmdlineSubstList* cmdline_subst);
  68. /* Adds a hashtree root digest to be substituted in $(AVB_*_ROOT_DIGEST)
  69. * variables. The partition name differentiates the variable. For example, if
  70. * |part_name| is "foo" then $(AVB_FOO_ROOT_DIGEST) will be substituted with the
  71. * hex encoding of the digest. The substitution will be added to
  72. * |out_cmdline_subst|. Returns AVB_SLOT_VERIFY_RESULT_OK on success.
  73. */
  74. AvbSlotVerifyResult avb_add_root_digest_substitution(
  75. const char* part_name,
  76. const uint8_t* digest,
  77. size_t digest_size,
  78. AvbCmdlineSubstList* out_cmdline_subst);
  79. #endif