| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 * | 4 * |
| 5 * Data structure definitions for verified boot, for on-disk / in-eeprom | 5 * Data structure definitions for verified boot, for on-disk / in-eeprom |
| 6 * data. | 6 * data. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_ | 9 #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_ |
| 10 #define VBOOT_REFERENCE_VBOOT_STRUCT_H_ | 10 #define VBOOT_REFERENCE_VBOOT_STRUCT_H_ |
| 11 | 11 |
| 12 #include "sysincludes.h" | 12 #include "sysincludes.h" |
| 13 | 13 |
| 14 PACK_START /* Support packing for MSVC */ |
| 14 | 15 |
| 15 /* Public key data */ | 16 /* Public key data */ |
| 16 typedef struct VbPublicKey { | 17 typedef struct VbPublicKey { |
| 17 uint64_t key_offset; /* Offset of key data from start of this struct */ | 18 uint64_t key_offset; /* Offset of key data from start of this struct */ |
| 18 uint64_t key_size; /* Size of key data in bytes (NOT strength of key | 19 uint64_t key_size; /* Size of key data in bytes (NOT strength of key |
| 19 * in bits) */ | 20 * in bits) */ |
| 20 uint64_t algorithm; /* Signature algorithm used by the key */ | 21 uint64_t algorithm; /* Signature algorithm used by the key */ |
| 21 uint64_t key_version; /* Key version */ | 22 uint64_t key_version; /* Key version */ |
| 22 } __attribute__((packed)) VbPublicKey; | 23 } __attribute__((packed)) VbPublicKey; |
| 23 | 24 |
| 25 #define EXPECTED_VBPUBLICKEY_SIZE 32 |
| 26 |
| 24 | 27 |
| 25 /* Signature data (a secure hash, possibly signed) */ | 28 /* Signature data (a secure hash, possibly signed) */ |
| 26 typedef struct VbSignature { | 29 typedef struct VbSignature { |
| 27 uint64_t sig_offset; /* Offset of signature data from start of this | 30 uint64_t sig_offset; /* Offset of signature data from start of this |
| 28 * struct */ | 31 * struct */ |
| 29 uint64_t sig_size; /* Size of signature data in bytes */ | 32 uint64_t sig_size; /* Size of signature data in bytes */ |
| 30 uint64_t data_size; /* Size of the data block which was signed in bytes */ | 33 uint64_t data_size; /* Size of the data block which was signed in bytes */ |
| 31 } __attribute__((packed)) VbSignature; | 34 } __attribute__((packed)) VbSignature; |
| 32 | 35 |
| 36 #define EXPECTED_VBSIGNATURE_SIZE 24 |
| 37 |
| 33 | 38 |
| 34 #define KEY_BLOCK_MAGIC "CHROMEOS" | 39 #define KEY_BLOCK_MAGIC "CHROMEOS" |
| 35 #define KEY_BLOCK_MAGIC_SIZE 8 | 40 #define KEY_BLOCK_MAGIC_SIZE 8 |
| 36 | 41 |
| 37 #define KEY_BLOCK_HEADER_VERSION_MAJOR 2 | 42 #define KEY_BLOCK_HEADER_VERSION_MAJOR 2 |
| 38 #define KEY_BLOCK_HEADER_VERSION_MINOR 1 | 43 #define KEY_BLOCK_HEADER_VERSION_MINOR 1 |
| 39 | 44 |
| 40 /* Flags for key_block_flags */ | 45 /* Flags for key_block_flags */ |
| 41 /* The following flags set where the key is valid */ | 46 /* The following flags set where the key is valid */ |
| 42 #define KEY_BLOCK_FLAG_DEVELOPER_0 UINT64_C(0x01) /* Developer switch off */ | 47 #define KEY_BLOCK_FLAG_DEVELOPER_0 UINT64_C(0x01) /* Developer switch off */ |
| (...skipping 19 matching lines...) Expand all Loading... |
| 62 uint64_t key_block_flags; /* Flags for key (KEY_BLOCK_FLAG_*) */ | 67 uint64_t key_block_flags; /* Flags for key (KEY_BLOCK_FLAG_*) */ |
| 63 VbPublicKey data_key; /* Key to verify the chunk of data */ | 68 VbPublicKey data_key; /* Key to verify the chunk of data */ |
| 64 } __attribute__((packed)) VbKeyBlockHeader; | 69 } __attribute__((packed)) VbKeyBlockHeader; |
| 65 /* This should be followed by: | 70 /* This should be followed by: |
| 66 * 1) The data_key key data, pointed to by data_key.key_offset. | 71 * 1) The data_key key data, pointed to by data_key.key_offset. |
| 67 * 2) The checksum data for (VBKeyBlockHeader + data_key data), pointed to | 72 * 2) The checksum data for (VBKeyBlockHeader + data_key data), pointed to |
| 68 * by key_block_checksum.sig_offset. | 73 * by key_block_checksum.sig_offset. |
| 69 * 3) The signature data for (VBKeyBlockHeader + data_key data), pointed to | 74 * 3) The signature data for (VBKeyBlockHeader + data_key data), pointed to |
| 70 * by key_block_signature.sig_offset. */ | 75 * by key_block_signature.sig_offset. */ |
| 71 | 76 |
| 77 #define EXPECTED_VBKEYBLOCKHEADER_SIZE 112 |
| 78 |
| 72 | 79 |
| 73 #define FIRMWARE_PREAMBLE_HEADER_VERSION_MAJOR 2 | 80 #define FIRMWARE_PREAMBLE_HEADER_VERSION_MAJOR 2 |
| 74 #define FIRMWARE_PREAMBLE_HEADER_VERSION_MINOR 0 | 81 #define FIRMWARE_PREAMBLE_HEADER_VERSION_MINOR 0 |
| 75 | 82 |
| 76 /* Preamble block for rewritable firmware */ | 83 /* Preamble block for rewritable firmware */ |
| 77 typedef struct VbFirmwarePreambleHeader { | 84 typedef struct VbFirmwarePreambleHeader { |
| 78 uint64_t preamble_size; /* Size of this preamble, including keys, | 85 uint64_t preamble_size; /* Size of this preamble, including keys, |
| 79 * signatures, and padding, in bytes */ | 86 * signatures, and padding, in bytes */ |
| 80 VbSignature preamble_signature; /* Signature for this preamble | 87 VbSignature preamble_signature; /* Signature for this preamble |
| 81 * (header + kernel subkey + | 88 * (header + kernel subkey + |
| 82 * body signature) */ | 89 * body signature) */ |
| 83 uint32_t header_version_major; /* Version of this header format */ | 90 uint32_t header_version_major; /* Version of this header format */ |
| 84 uint32_t header_version_minor; /* Version of this header format */ | 91 uint32_t header_version_minor; /* Version of this header format */ |
| 85 | 92 |
| 86 uint64_t firmware_version; /* Firmware version */ | 93 uint64_t firmware_version; /* Firmware version */ |
| 87 VbPublicKey kernel_subkey; /* Key to verify kernel key block */ | 94 VbPublicKey kernel_subkey; /* Key to verify kernel key block */ |
| 88 VbSignature body_signature; /* Signature for the firmware body */ | 95 VbSignature body_signature; /* Signature for the firmware body */ |
| 89 } __attribute__((packed)) VbFirmwarePreambleHeader; | 96 } __attribute__((packed)) VbFirmwarePreambleHeader; |
| 90 /* This should be followed by: | 97 /* This should be followed by: |
| 91 * 1) The kernel_subkey key data, pointed to by kernel_subkey.key_offset. | 98 * 1) The kernel_subkey key data, pointed to by kernel_subkey.key_offset. |
| 92 * 2) The signature data for the firmware body, pointed to by | 99 * 2) The signature data for the firmware body, pointed to by |
| 93 * body_signature.sig_offset. | 100 * body_signature.sig_offset. |
| 94 * 3) The signature data for (VBFirmwarePreambleHeader + kernel_subkey data | 101 * 3) The signature data for (VBFirmwarePreambleHeader + kernel_subkey data |
| 95 * + body signature data), pointed to by | 102 * + body signature data), pointed to by |
| 96 * preamble_signature.sig_offset. */ | 103 * preamble_signature.sig_offset. */ |
| 97 | 104 |
| 105 #define EXPECTED_VBFIRMWAREPREAMBLEHEADER_SIZE 104 |
| 98 | 106 |
| 99 #define KERNEL_PREAMBLE_HEADER_VERSION_MAJOR 2 | 107 #define KERNEL_PREAMBLE_HEADER_VERSION_MAJOR 2 |
| 100 #define KERNEL_PREAMBLE_HEADER_VERSION_MINOR 0 | 108 #define KERNEL_PREAMBLE_HEADER_VERSION_MINOR 0 |
| 101 | 109 |
| 102 /* Preamble block for kernel */ | 110 /* Preamble block for kernel */ |
| 103 typedef struct VbKernelPreambleHeader { | 111 typedef struct VbKernelPreambleHeader { |
| 104 uint64_t preamble_size; /* Size of this preamble, including keys, | 112 uint64_t preamble_size; /* Size of this preamble, including keys, |
| 105 * signatures, and padding, in bytes */ | 113 * signatures, and padding, in bytes */ |
| 106 VbSignature preamble_signature; /* Signature for this preamble | 114 VbSignature preamble_signature; /* Signature for this preamble |
| 107 * (header + body signature) */ | 115 * (header + body signature) */ |
| 108 uint32_t header_version_major; /* Version of this header format */ | 116 uint32_t header_version_major; /* Version of this header format */ |
| 109 uint32_t header_version_minor; /* Version of this header format */ | 117 uint32_t header_version_minor; /* Version of this header format */ |
| 110 | 118 |
| 111 uint64_t kernel_version; /* Kernel version */ | 119 uint64_t kernel_version; /* Kernel version */ |
| 112 uint64_t body_load_address; /* Load address for kernel body */ | 120 uint64_t body_load_address; /* Load address for kernel body */ |
| 113 uint64_t bootloader_address; /* Address of bootloader, after body is | 121 uint64_t bootloader_address; /* Address of bootloader, after body is |
| 114 * loaded at body_load_address */ | 122 * loaded at body_load_address */ |
| 115 uint64_t bootloader_size; /* Size of bootloader in bytes */ | 123 uint64_t bootloader_size; /* Size of bootloader in bytes */ |
| 116 VbSignature body_signature; /* Signature for the kernel body */ | 124 VbSignature body_signature; /* Signature for the kernel body */ |
| 117 } __attribute__((packed)) VbKernelPreambleHeader; | 125 } __attribute__((packed)) VbKernelPreambleHeader; |
| 118 /* This should be followed by: | 126 /* This should be followed by: |
| 119 * 2) The signature data for the kernel body, pointed to by | 127 * 2) The signature data for the kernel body, pointed to by |
| 120 * body_signature.sig_offset. | 128 * body_signature.sig_offset. |
| 121 * 3) The signature data for (VBFirmwarePreambleHeader + body signature | 129 * 3) The signature data for (VBFirmwarePreambleHeader + body signature |
| 122 * data), pointed to by preamble_signature.sig_offset. */ | 130 * data), pointed to by preamble_signature.sig_offset. */ |
| 123 | 131 |
| 132 #define EXPECTED_VBKERNELPREAMBLEHEADER_SIZE 96 |
| 133 |
| 134 |
| 135 PACK_STOP /* Support packing for MSVC */ |
| 136 |
| 124 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */ | 137 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */ |
| OLD | NEW |