avb_chain_partition_descriptor.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2016 The Android Open Source Project
  3. *
  4. * SPDX-License-Identifier: MIT
  5. */
  6. #if !defined(AVB_INSIDE_LIBAVB_H) && !defined(AVB_COMPILATION)
  7. #error "Never include this file directly, include libavb.h instead."
  8. #endif
  9. #ifndef AVB_CHAIN_PARTITION_DESCRIPTOR_H_
  10. #define AVB_CHAIN_PARTITION_DESCRIPTOR_H_
  11. #include "avb_descriptor.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* A descriptor containing a pointer to signed integrity data stored
  16. * on another partition. The descriptor contains the partition name in
  17. * question (without the A/B suffix), the public key used to sign the
  18. * integrity data, and rollback index location to use for rollback
  19. * protection.
  20. *
  21. * Following this struct are |partition_name_len| bytes of the
  22. * partition name (UTF-8 encoded) and |public_key_len| bytes of the
  23. * public key.
  24. *
  25. * The |reserved| field is for future expansion and must be set to NUL
  26. * bytes.
  27. */
  28. typedef struct AvbChainPartitionDescriptor {
  29. AvbDescriptor parent_descriptor;
  30. uint32_t rollback_index_location;
  31. uint32_t partition_name_len;
  32. uint32_t public_key_len;
  33. uint8_t reserved[64];
  34. } AVB_ATTR_PACKED AvbChainPartitionDescriptor;
  35. /* Copies |src| to |dest| and validates, byte-swapping fields in the
  36. * process if needed. Returns true if valid, false if invalid.
  37. *
  38. * Data following the struct is not validated nor copied.
  39. */
  40. bool avb_chain_partition_descriptor_validate_and_byteswap(
  41. const AvbChainPartitionDescriptor* src,
  42. AvbChainPartitionDescriptor* dest) AVB_ATTR_WARN_UNUSED_RESULT;
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif /* AVB_CHAIN_PARTITION_DESCRIPTOR_H_ */