| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef VBOOT_REFERENCE_2SECDATA_STRUCT_H_ |
| 9 |
#define VBOOT_REFERENCE_2SECDATA_STRUCT_H_ |
| 10 |
|
| 11 |
#include "2constants.h" |
| 12 |
#include "2crc8.h" |
| 13 |
#include "2sha.h" |
| 14 |
#include "2sysincludes.h" |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#define VB2_SECDATA_FIRMWARE_VERSION 2 |
| 20 |
|
| 21 |
struct vb2_secdata_firmware { |
| 22 |
|
| 23 |
uint8_t struct_version; |
| 24 |
|
| 25 |
|
| 26 |
uint8_t flags; |
| 27 |
|
| 28 |
|
| 29 |
uint32_t fw_versions; |
| 30 |
|
| 31 |
|
| 32 |
uint8_t reserved[3]; |
| 33 |
|
| 34 |
|
| 35 |
uint8_t crc8; |
| 36 |
} __attribute__((packed)); |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
#define VB2_SECDATA_KERNEL_VERSION_V02 (0 << 4 | 2 << 0) |
| 52 |
#define VB2_SECDATA_KERNEL_VERSION_V10 (1 << 4 | 0 << 0) |
| 53 |
#define VB2_SECDATA_KERNEL_VERSION_LATEST VB2_SECDATA_KERNEL_VERSION_V10 |
| 54 |
#define VB2_SECDATA_KERNEL_UID 0x4752574c |
| 55 |
|
| 56 |
struct vb2_secdata_kernel_v0 { |
| 57 |
|
| 58 |
uint8_t struct_version; |
| 59 |
|
| 60 |
|
| 61 |
uint32_t uid; |
| 62 |
|
| 63 |
|
| 64 |
uint32_t kernel_versions; |
| 65 |
|
| 66 |
|
| 67 |
uint8_t reserved[3]; |
| 68 |
|
| 69 |
|
| 70 |
uint8_t crc8; |
| 71 |
} __attribute__((packed)); |
| 72 |
_Static_assert(sizeof(struct vb2_secdata_kernel_v0) |
| 73 |
== VB2_SECDATA_KERNEL_SIZE_V02, |
| 74 |
"VB2_SECDATA_KERNEL_SIZE_V02 incorrect"); |
| 75 |
_Static_assert(sizeof(struct vb2_secdata_kernel_v0) |
| 76 |
< VB2_SECDATA_KERNEL_MAX_SIZE, |
| 77 |
"VB2_SECDATA_KERNEL_SIZE_V02 exceeds max size"); |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
struct vb2_secdata_kernel_v1 { |
| 83 |
|
| 84 |
uint8_t struct_version; |
| 85 |
|
| 86 |
|
| 87 |
uint8_t struct_size; |
| 88 |
|
| 89 |
|
| 90 |
uint8_t crc8; |
| 91 |
|
| 92 |
|
| 93 |
uint8_t flags; |
| 94 |
|
| 95 |
|
| 96 |
uint32_t kernel_versions; |
| 97 |
|
| 98 |
|
| 99 |
uint8_t ec_hash[VB2_SHA256_DIGEST_SIZE]; |
| 100 |
}; |
| 101 |
_Static_assert(sizeof(struct vb2_secdata_kernel_v1) |
| 102 |
== VB2_SECDATA_KERNEL_SIZE_V10, |
| 103 |
"VB2_SECDATA_KERNEL_SIZE_V10 incorrect"); |
| 104 |
_Static_assert(sizeof(struct vb2_secdata_kernel_v1) |
| 105 |
< VB2_SECDATA_KERNEL_MAX_SIZE, |
| 106 |
"VB2_SECDATA_KERNEL_SIZE_V10 exceeds max size"); |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
#define VB2_SECDATA_FWMP_VERSION 0x10 |
| 112 |
#define VB2_SECDATA_FWMP_HASH_SIZE 32 |
| 113 |
|
| 114 |
struct vb2_secdata_fwmp { |
| 115 |
|
| 116 |
uint8_t crc8; |
| 117 |
|
| 118 |
|
| 119 |
uint8_t struct_size; |
| 120 |
|
| 121 |
|
| 122 |
uint8_t struct_version; |
| 123 |
|
| 124 |
|
| 125 |
uint8_t reserved0; |
| 126 |
|
| 127 |
|
| 128 |
uint32_t flags; |
| 129 |
|
| 130 |
|
| 131 |
uint8_t dev_key_hash[VB2_SECDATA_FWMP_HASH_SIZE]; |
| 132 |
}; |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
static inline uint32_t vb2_secdata_fwmp_crc(struct vb2_secdata_fwmp *sec) |
| 144 |
{ |
| 145 |
int version_offset = offsetof(struct vb2_secdata_fwmp, struct_version); |
| 146 |
return vb2_crc8((void *)sec + version_offset, |
| 147 |
sec->struct_size - version_offset); |
| 148 |
} |
| 149 |
|
| 150 |
#endif |