Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Side by Side Diff: src/platform/vboot_reference/vboot_firmware/include/kernel_image_fw.h

Issue 2292001: Make kernel signature a part of the kernel preamble. (Closed) Base URL: ssh://git@gitrw.chromium.org/chromiumos
Patch Set: Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 and API definitions for a verified boot kernel image. 5 * Data structure and API definitions for a verified boot kernel image.
6 * (Firmware Portion) 6 * (Firmware Portion)
7 */ 7 */
8 8
9 #ifndef VBOOT_REFERENCE_KERNEL_IMAGE_FW_H_ 9 #ifndef VBOOT_REFERENCE_KERNEL_IMAGE_FW_H_
10 #define VBOOT_REFERENCE_KERNEL_IMAGE_FW_H_ 10 #define VBOOT_REFERENCE_KERNEL_IMAGE_FW_H_
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 * key_version] */ 42 * key_version] */
43 /* End of kernel key header. */ 43 /* End of kernel key header. */
44 uint8_t* kernel_key_signature; /* Signature of the header above. */ 44 uint8_t* kernel_key_signature; /* Signature of the header above. */
45 45
46 /* Kernel preamble */ 46 /* Kernel preamble */
47 uint16_t kernel_version; /* Kernel Version# for preventing rollbacks. */ 47 uint16_t kernel_version; /* Kernel Version# for preventing rollbacks. */
48 uint64_t kernel_len; /* Length of the actual kernel image. */ 48 uint64_t kernel_len; /* Length of the actual kernel image. */
49 uint64_t bootloader_offset; /* Offset of bootloader in kernel_data. */ 49 uint64_t bootloader_offset; /* Offset of bootloader in kernel_data. */
50 uint64_t bootloader_size; /* Size of bootloader in bytes. */ 50 uint64_t bootloader_size; /* Size of bootloader in bytes. */
51 uint64_t padded_header_size; /* start of kernel_data in disk partition */ 51 uint64_t padded_header_size; /* start of kernel_data in disk partition */
52 uint8_t* kernel_signature; /* Signature on [kernel_data] below.
53 * NOTE: This is only considered valid
54 * if preamble_signature successfully verifies. */
52 /* end of preamble */ 55 /* end of preamble */
53 56 uint8_t* preamble_signature; /* signature on preamble, (includes
54 uint8_t* preamble_signature; /* Signature on the kernel preamble. */ 57 [kernel_signature]) */
55
56 /* The kernel signature comes first as it may allow us to parallelize
57 * the kernel data fetch and RSA public key operation.
58 */
59 uint8_t* kernel_signature; /* Signature on the concatenation of
60 * the kernel preamble and [kernel_data]. */
61 uint8_t* kernel_data; /* Actual kernel data. */ 58 uint8_t* kernel_data; /* Actual kernel data. */
62 59
63 } KernelImage; 60 } KernelImage;
64 61
65 /* Error Codes for VerifyFirmware. */ 62 /* Error Codes for VerifyFirmware. */
66 #define VERIFY_KERNEL_SUCCESS 0 63 #define VERIFY_KERNEL_SUCCESS 0
67 #define VERIFY_KERNEL_INVALID_IMAGE 1 64 #define VERIFY_KERNEL_INVALID_IMAGE 1
68 #define VERIFY_KERNEL_KEY_SIGNATURE_FAILED 2 65 #define VERIFY_KERNEL_KEY_SIGNATURE_FAILED 2
69 #define VERIFY_KERNEL_INVALID_ALGORITHM 3 66 #define VERIFY_KERNEL_INVALID_ALGORITHM 3
70 #define VERIFY_KERNEL_PREAMBLE_SIGNATURE_FAILED 4 67 #define VERIFY_KERNEL_PREAMBLE_SIGNATURE_FAILED 4
71 #define VERIFY_KERNEL_SIGNATURE_FAILED 5 68 #define VERIFY_KERNEL_SIGNATURE_FAILED 5
72 #define VERIFY_KERNEL_WRONG_MAGIC 6 69 #define VERIFY_KERNEL_WRONG_MAGIC 6
73 #define VERIFY_KERNEL_MAX 7 /* Generic catch-all. */ 70 #define VERIFY_KERNEL_MAX 7 /* Generic catch-all. */
74 71
75 extern char* kVerifyKernelErrors[VERIFY_KERNEL_MAX]; 72 extern char* kVerifyKernelErrors[VERIFY_KERNEL_MAX];
76 73
77 /* Returns the length of the verified boot kernel preamble. */ 74 /* Returns the length of the verified boot kernel preamble based on
78 uint64_t GetKernelPreambleLen(void); 75 * kernel signing algorithm [algorithm]. */
76 uint64_t GetKernelPreambleLen(int algorithm);
79 77
80 /* Returns the length of the Kernel Verified Boot header excluding 78 /* Returns the length of the Kernel Verified Boot header excluding
81 * [kernel_data]. 79 * [kernel_data].
82 * 80 *
83 * This is always non-zero, so a return value of 0 signifies an error. 81 * This is always non-zero, so a return value of 0 signifies an error.
84 */ 82 */
85 uint64_t GetVBlockHeaderSize(const uint8_t* vkernel_blob); 83 uint64_t GetVBlockHeaderSize(const uint8_t* vkernel_blob);
86 84
87 /* Checks for the sanity of the kernel key header at [kernel_header_blob]. 85 /* Checks for the sanity of the kernel key header at [kernel_header_blob].
88 * If [dev_mode] is enabled, also checks the kernel key signature using the 86 * If [dev_mode] is enabled, also checks the kernel key signature using the
(...skipping 15 matching lines...) Expand all
104 * using the signing key [kernel_sign_key]. 102 * using the signing key [kernel_sign_key].
105 * 103 *
106 * On success, put kernel length into [kernel_len], and return 0. 104 * On success, put kernel length into [kernel_len], and return 0.
107 * Else, return error code on failure. 105 * Else, return error code on failure.
108 */ 106 */
109 int VerifyKernelPreamble(RSAPublicKey* kernel_sign_key, 107 int VerifyKernelPreamble(RSAPublicKey* kernel_sign_key,
110 const uint8_t* kernel_preamble_blob, 108 const uint8_t* kernel_preamble_blob,
111 int algorithm, 109 int algorithm,
112 uint64_t* kernel_len); 110 uint64_t* kernel_len);
113 111
114 /* Checks the signature on the kernel data at location [kernel_data_start]. 112 /* Checks [kernel_signature] on the kernel data at location [kernel_data]. The
115 * The length of the actual kernel data is kernel_len and it is assumed to 113 * signature is assumed to be generated using algorithm [algorithm].
116 * be prepended with the signature whose size depends on the signature_algorithm 114 * The length of the kernel data is [kernel_len].
117 * [algorithm].
118 * 115 *
119 * Return 0 on success, error code on failure. 116 * Return 0 on success, error code on failure.
120 */ 117 */
121 int VerifyKernelData(RSAPublicKey* kernel_sign_key, 118 int VerifyKernelData(RSAPublicKey* kernel_sign_key,
122 const uint8_t* kernel_config_start, 119 const uint8_t* kernel_signature,
123 const uint8_t* kernel_data_start, 120 const uint8_t* kernel_data,
124 uint64_t kernel_len, 121 uint64_t kernel_len,
125 int algorithm); 122 int algorithm);
126 123
127 /* Verifies the kernel key header and preamble at [kernel_header_blob] 124 /* Verifies the kernel key header and preamble at [kernel_header_blob]
128 * using the firmware public key [firmware_key_blob]. If [dev_mode] is 1 125 * using the firmware public key [firmware_key_blob]. If [dev_mode] is 1
129 * (active), then key header verification is skipped. 126 * (active), then key header verification is skipped.
130 * 127 *
131 * Fills in a pointer to preamble blob within [kernel_header_blob] in 128 * Fills in a pointer to expected kernel data signature
132 * [preamble_blob], pointer to expected kernel data signature
133 * within [kernel_header_blob] in [expected_kernel_signature]. 129 * within [kernel_header_blob] in [expected_kernel_signature].
134 * 130 *
135 * The signing key to use for kernel data verification is returned in 131 * The signing key to use for kernel data verification is returned in
136 * [kernel_sign_key], This must be free-d explicitly by the caller after use. 132 * [kernel_sign_key], This must be free-d explicitly by the caller after use.
137 * The kernel signing algorithm is returned in [kernel_sign_algorithm] and its 133 * The kernel signing algorithm is returned in [kernel_sign_algorithm] and its
138 * length in [kernel_len]. 134 * length in [kernel_len].
139 * 135 *
140 * Returns 0 on success, error code on failure. 136 * Returns 0 on success, error code on failure.
141 */ 137 */
142 int VerifyKernelHeader(const uint8_t* firmware_key_blob, 138 int VerifyKernelHeader(const uint8_t* firmware_key_blob,
143 const uint8_t* kernel_header_blob, 139 const uint8_t* kernel_header_blob,
144 const int dev_mode, 140 const int dev_mode,
145 const uint8_t** preamble_blob,
146 const uint8_t** expected_kernel_signature, 141 const uint8_t** expected_kernel_signature,
147 RSAPublicKey** kernel_sign_key, 142 RSAPublicKey** kernel_sign_key,
148 int* kernel_sign_algorithm, 143 int* kernel_sign_algorithm,
149 uint64_t* kernel_len); 144 uint64_t* kernel_len);
150 145
151 /* Performs a chained verify of the kernel blob [kernel_blob]. If 146 /* Performs a chained verify of the kernel blob [kernel_blob]. If
152 * [dev_mode] is 0 [inactive], then the pre-processed public signing key 147 * [dev_mode] is 0 [inactive], then the pre-processed public signing key
153 * [root_key_blob] is used to verify the signature of the signing key, 148 * [root_key_blob] is used to verify the signature of the signing key,
154 * else the check is skipped. 149 * else the check is skipped.
155 * 150 *
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 * BOOT_KERNEL_A_CONTINUE Boot from Kenrel A 193 * BOOT_KERNEL_A_CONTINUE Boot from Kenrel A
199 * BOOT_KERNEL_B_CONTINUE Boot from Kernel B 194 * BOOT_KERNEL_B_CONTINUE Boot from Kernel B
200 * BOOT_KERNEL_RECOVERY_CONTINUE Jump to recovery mode 195 * BOOT_KERNEL_RECOVERY_CONTINUE Jump to recovery mode
201 */ 196 */
202 int VerifyKernelDriver_f(uint8_t* firmware_key_blob, 197 int VerifyKernelDriver_f(uint8_t* firmware_key_blob,
203 kernel_entry* kernelA, 198 kernel_entry* kernelA,
204 kernel_entry* kernelB, 199 kernel_entry* kernelB,
205 int dev_mode); 200 int dev_mode);
206 201
207 #endif /* VBOOT_REFERENCE_KERNEL_IMAGE_FW_H_ */ 202 #endif /* VBOOT_REFERENCE_KERNEL_IMAGE_FW_H_ */
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/tests/test_common.c ('k') | src/platform/vboot_reference/vboot_firmware/lib/kernel_image_fw.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698