OLD | NEW |
---|---|
(Empty) | |
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 | |
3 * found in the LICENSE file. | |
4 * | |
5 * Data structure definitions for verified boot, for on-disk / in-eeprom | |
6 * data. | |
7 */ | |
8 | |
9 #ifndef VBOOT_REFERENCE_VBOOT_STRUCT_H_ | |
10 #define VBOOT_REFERENCE_VBOOT_STRUCT_H_ | |
11 | |
12 #include <stdint.h> | |
13 | |
14 | |
15 /* Public key data */ | |
16 typedef struct VbPublicKey { | |
17 uint64_t key_offset; /* Offset of key data from start of this struct */ | |
18 uint64_t key_size; /* Size of key data in bytes */ | |
19 uint64_t algorithm; /* Signature algorithm used by the key */ | |
20 uint64_t key_version; /* Key version */ | |
21 } VbPublicKey; | |
22 | |
23 | |
24 /* Signature data (a secure hash, possibly signed) */ | |
25 typedef struct VbSignature { | |
26 uint64_t sig_offset; /* Offset of signature data from start of this | |
27 * struct */ | |
28 uint64_t sig_size; /* Size of signature data from start of this struct */ | |
vb
2010/06/10 17:37:49
Shouldn't this be just 'size of signature data'?
| |
29 uint64_t data_size; /* Size of the data block which was signed in bytes */ | |
30 } VbSignature; | |
31 | |
32 | |
33 #define KEY_BLOCK_MAGIC "CHROMEOS" | |
34 #define KEY_BLOCK_MAGIC_SIZE 8 | |
vb
2010/06/10 17:37:49
would be more robust defined as (sizeof(KEY_BLOCK_
| |
35 | |
36 #define KEY_BLOCK_HEADER_VERSION_MAJOR 2 | |
37 #define KEY_BLOCK_HEADER_VERSION_MINOR 1 | |
38 | |
39 /* Flags for key_block_flags */ | |
40 /* The following flags set where the key is valid */ | |
41 #define KEY_BLOCK_FLAG_DEVELOPER_0 0x01ULL /* Developer switch off */ | |
gauravsh
2010/06/10 14:44:13
UINT64_C(0x01) instead?
| |
42 #define KEY_BLOCK_FLAG_DEVELOPER_1 0x02ULL /* Developer switch on */ | |
43 #define KEY_BLOCK_FLAG_RECOVERY_0 0x04ULL /* Not recovery mode */ | |
44 #define KEY_BLOCK_FLAG_RECOVERY_1 0x08ULL /* Recovery mode */ | |
45 | |
46 /* Key block, containing the public key used to sign some other chunk | |
47 * of data. */ | |
48 typedef struct VbKeyBlockHeader { | |
49 uint8_t magic[KEY_BLOCK_MAGIC_SIZE]; /* Magic number */ | |
50 uint32_t header_version_major; /* Version of this header format */ | |
51 uint32_t header_version_minor; /* Version of this header format */ | |
52 uint64_t key_block_size; /* Length of this entire key block, | |
53 * including keys, signatures, and | |
54 * padding, in bytes */ | |
55 VbSignature key_block_signature; /* Signature for this key block | |
56 * (header + data pointed to by data_key) | |
57 * For use with signed data keys*/ | |
58 VbSignature key_block_checksum; /* SHA-512 checksum for this key block | |
59 * (header + data pointed to by data_key) | |
60 * For use with unsigned data keys */ | |
61 uint64_t key_block_flags; /* Flags for key (KEY_BLOCK_FLAG_*) */ | |
62 VbPublicKey data_key; /* Key to verify the chunk of data */ | |
63 } VbKeyBlockHeader; | |
64 /* This should be followed by: | |
65 * 1) The data_key key data, pointed to by data_key.key_offset. | |
66 * 2) The checksum data for (VBKeyBlockHeader + data_key data), pointed to | |
67 * by key_block_checksum.sig_offset. | |
68 * 3) The signature data for (VBKeyBlockHeader + data_key data), pointed to | |
69 * by key_block_signature.sig_offset. */ | |
70 | |
71 | |
72 #define FIRMWARE_PREAMBLE_HEADER_VERSION_MAJOR 2 | |
73 #define FIRMWARE_PREAMBLE_HEADER_VERSION_MINOR 0 | |
74 | |
75 /* Preamble block for rewritable firmware */ | |
76 typedef struct VbFirmwarePreambleHeader { | |
77 uint64_t preamble_size; /* Size of this preamble, including keys, | |
78 * signatures, and padding, in bytes */ | |
79 VbSignature preamble_signature; /* Signature for this preamble | |
80 * (header + kernel subkey + | |
81 * body signature) */ | |
82 uint32_t header_version_major; /* Version of this header format */ | |
83 uint32_t header_version_minor; /* Version of this header format */ | |
84 | |
85 uint64_t firmware_version; /* Firmware version */ | |
86 VbPublicKey kernel_subkey; /* Key to verify kernel key block */ | |
87 VbSignature body_signature; /* Signature for the firmware body */ | |
88 } VbFirmwarePreambleHeader; | |
89 /* This should be followed by: | |
90 * 1) The kernel_subkey key data, pointed to by kernel_subkey.key_offset. | |
91 * 2) The signature data for the firmware body, pointed to by | |
92 * body_signature.sig_offset. | |
93 * 3) The signature data for (VBFirmwarePreambleHeader + kernel_subkey data | |
94 * + body signature data), pointed to by | |
95 * preamble_signature.sig_offset. */ | |
96 | |
97 | |
98 #define KERNEL_PREAMBLE_HEADER_VERSION_MAJOR 2 | |
99 #define KERNEL_PREAMBLE_HEADER_VERSION_MINOR 0 | |
100 | |
101 /* Preamble block for kernel */ | |
102 typedef struct VbKernelPreambleHeader { | |
103 uint64_t preamble_size; /* Size of this preamble, including keys, | |
104 * signatures, and padding, in bytes */ | |
105 VbSignature preamble_signature; /* Signature for this preamble | |
106 * (header + body signature) */ | |
107 uint32_t header_version_major; /* Version of this header format */ | |
108 uint32_t header_version_minor; /* Version of this header format */ | |
109 | |
110 uint64_t kernel_version; /* Kernel version */ | |
111 uint64_t body_load_address; /* Load address for kernel body */ | |
112 uint64_t bootloader_address; /* Address of bootloader, after body is | |
113 * loaded at body_load_address */ | |
114 uint64_t bootloader_size; /* Size of bootloader in bytes */ | |
115 VbSignature body_signature; /* Signature for the kernel body */ | |
116 } VbKernelPreambleHeader; | |
117 /* This should be followed by: | |
118 * 2) The signature data for the kernel body, pointed to by | |
119 * body_signature.sig_offset. | |
120 * 3) The signature data for (VBFirmwarePreambleHeader + body signature | |
121 * data), pointed to by preamble_signature.sig_offset. */ | |
122 | |
123 #endif /* VBOOT_REFERENCE_VBOOT_STRUCT_H_ */ | |
OLD | NEW |