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