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

Side by Side Diff: firmware/lib/vboot_firmware.c

Issue 6596081: Add crossystem support for nvram_cleared and kern_nv (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Fix try B count mask Created 9 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | firmware/lib/vboot_nvstorage.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * High-level firmware API for loading and verifying rewritable firmware. 5 * High-level firmware API for loading and verifying rewritable firmware.
6 * (Firmware portion) 6 * (Firmware portion)
7 */ 7 */
8 8
9 #include "load_firmware_fw.h" 9 #include "load_firmware_fw.h"
10 #include "rollback_index.h" 10 #include "rollback_index.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 for (i = 0; i < 2; i++) { 109 for (i = 0; i < 2; i++) {
110 VbKeyBlockHeader* key_block; 110 VbKeyBlockHeader* key_block;
111 uint64_t vblock_size; 111 uint64_t vblock_size;
112 VbFirmwarePreambleHeader* preamble; 112 VbFirmwarePreambleHeader* preamble;
113 RSAPublicKey* data_key; 113 RSAPublicKey* data_key;
114 uint64_t key_version; 114 uint64_t key_version;
115 uint64_t combined_version; 115 uint64_t combined_version;
116 uint8_t* body_digest; 116 uint8_t* body_digest;
117 117
118 /* If try B count is non-zero try firmware B first */ 118 /* If try B count is non-zero try firmware B first */
119 index = (try_b_count ? i : 1 - i); 119 index = (try_b_count ? 1 - i : i);
120
121 /* Verify the key block */
122 VBPERFSTART("VB_VKB");
123 if (0 == index) { 120 if (0 == index) {
124 key_block = (VbKeyBlockHeader*)params->verification_block_0; 121 key_block = (VbKeyBlockHeader*)params->verification_block_0;
125 vblock_size = params->verification_size_0; 122 vblock_size = params->verification_size_0;
126 } else { 123 } else {
127 key_block = (VbKeyBlockHeader*)params->verification_block_1; 124 key_block = (VbKeyBlockHeader*)params->verification_block_1;
128 vblock_size = params->verification_size_1; 125 vblock_size = params->verification_size_1;
129 } 126 }
130 if ((0 != KeyBlockVerify(key_block, vblock_size, root_key, 0))) {
131 VBDEBUG(("Key block verification failed.\n"));
132 VBPERFEND("VB_VKB");
133 continue;
134 }
135 VBPERFEND("VB_VKB");
136 127
137 /* Check the key block flags against the current boot mode. */ 128 /* Check the key block flags against the current boot mode. Do this
129 * before verifying the key block, since flags are faster to check than
130 * the RSA signature. */
138 if (!(key_block->key_block_flags & 131 if (!(key_block->key_block_flags &
139 (is_dev ? KEY_BLOCK_FLAG_DEVELOPER_1 : 132 (is_dev ? KEY_BLOCK_FLAG_DEVELOPER_1 :
140 KEY_BLOCK_FLAG_DEVELOPER_0))) { 133 KEY_BLOCK_FLAG_DEVELOPER_0))) {
141 VBDEBUG(("Developer flag mismatch.\n")); 134 VBDEBUG(("Developer flag mismatch.\n"));
142 continue; 135 continue;
143 } 136 }
144 /* RW firmware never runs in recovery mode. */ 137 /* RW firmware never runs in recovery mode. */
145 if (!(key_block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_0)) { 138 if (!(key_block->key_block_flags & KEY_BLOCK_FLAG_RECOVERY_0)) {
146 VBDEBUG(("Recovery flag mismatch.\n")); 139 VBDEBUG(("Recovery flag mismatch.\n"));
147 continue; 140 continue;
148 } 141 }
149 142
143 /* Verify the key block */
144 VBPERFSTART("VB_VKB");
145 if ((0 != KeyBlockVerify(key_block, vblock_size, root_key, 0))) {
146 VBDEBUG(("Key block verification failed.\n"));
147 VBPERFEND("VB_VKB");
148 continue;
149 }
150 VBPERFEND("VB_VKB");
151
150 /* Check for rollback of key version. */ 152 /* Check for rollback of key version. */
151 key_version = key_block->data_key.key_version; 153 key_version = key_block->data_key.key_version;
152 if (key_version < (tpm_version >> 16)) { 154 if (key_version < (tpm_version >> 16)) {
153 VBDEBUG(("Key rollback detected.\n")); 155 VBDEBUG(("Key rollback detected.\n"));
154 continue; 156 continue;
155 } 157 }
156 158
157 /* Get the key for preamble/data verification from the key block. */ 159 /* Get the key for preamble/data verification from the key block. */
158 data_key = PublicKeyToRSA(&key_block->data_key); 160 data_key = PublicKeyToRSA(&key_block->data_key);
159 if (!data_key) { 161 if (!data_key) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 uint32_t status = RollbackS3Resume(); 323 uint32_t status = RollbackS3Resume();
322 324
323 /* If we can't resume, just do a full reboot. No need to go to recovery 325 /* If we can't resume, just do a full reboot. No need to go to recovery
324 * mode here, since if the TPM is really broken we'll catch it on the 326 * mode here, since if the TPM is really broken we'll catch it on the
325 * next boot. */ 327 * next boot. */
326 if (status == TPM_SUCCESS) 328 if (status == TPM_SUCCESS)
327 return LOAD_FIRMWARE_SUCCESS; 329 return LOAD_FIRMWARE_SUCCESS;
328 else 330 else
329 return LOAD_FIRMWARE_REBOOT; 331 return LOAD_FIRMWARE_REBOOT;
330 } 332 }
OLDNEW
« no previous file with comments | « no previous file | firmware/lib/vboot_nvstorage.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698