| 1 | /* Copyright 2021 The ChromiumOS Authors |
| 2 | * Use of this source code is governed by a BSD-style license that can be |
| 3 | * found in the LICENSE file. |
| 4 | */ |
| 5 | |
| 6 | #ifndef __VBOOT_REFERENCE_HOST_LIB_INCLUDE_GSC_RO_H |
| 7 | #define __VBOOT_REFERENCE_HOST_LIB_INCLUDE_GSC_RO_H |
| 8 | |
| 9 | #include <stddef.h> |
| 10 | #include <stdint.h> |
| 11 | |
| 12 | #include "2sha.h" |
| 13 | |
| 14 | struct gscvd_ro_range { |
| 15 | uint32_t offset; |
| 16 | uint32_t size; /* Use uint32_t as opposed to size_to be portable. */ |
| 17 | }; |
| 18 | |
| 19 | #define GSC_VD_MAGIC 0x65666135 /* Little endian '5 a f e' */ |
| 20 | #define GSC_VD_ROLLBACK_COUNTER 1 |
| 21 | |
| 22 | struct gsc_verification_data { |
| 23 | uint32_t gv_magic; |
| 24 | /* |
| 25 | * Size of this structure in bytes, including the ranges array, |
| 26 | * signature and root key bodies. |
| 27 | */ |
| 28 | uint16_t size; |
| 29 | uint16_t major_version; /* Version of this struct layout. Starts at 0 */ |
| 30 | uint16_t minor_version; |
| 31 | /* |
| 32 | * GSC will cache the counter value and will not accept verification |
| 33 | * data blobs with a lower value. |
| 34 | */ |
| 35 | uint16_t rollback_counter; |
| 36 | uint32_t gsc_board_id; /* Locks blob to certain platform. */ |
| 37 | uint32_t gsc_flags; /* A field for future enhancements. */ |
| 38 | /* |
| 39 | * The location of fmap that points to this blob. This location must |
| 40 | * also be in one of the verified sections, expressed as offset in |
| 41 | * flash |
| 42 | */ |
| 43 | uint32_t fmap_location; |
| 44 | uint32_t hash_alg; /* one of enum vb2_hash_algorithm alg. */ |
| 45 | struct vb2_signature sig_header; |
| 46 | struct vb2_packed_key root_key_header; |
| 47 | /* |
| 48 | * SHAxxx(ranges[0].offset..ranges[0].size || ... || |
| 49 | * ranges[n].offset..ranges[n].size) |
| 50 | * |
| 51 | * Let the digest space allow to accommodate the largest possible one. |
| 52 | */ |
| 53 | uint8_t ranges_digest[VB2_SHA512_DIGEST_SIZE]; |
| 54 | uint32_t range_count; /* Number of gscvd_ro_range entries. */ |
| 55 | struct gscvd_ro_range ranges[0]; |
| 56 | }; |
| 57 | |
| 58 | #endif /* ! __VBOOT_REFERENCE_HOST_LIB_INCLUDE_GSC_RO_H */ |