avb_chain_partition_descriptor.h 1.6 KB

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