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