| 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 * 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 "vboot_firmware.h" | |
| 10 | |
| 11 #include "load_firmware_fw.h" | 9 #include "load_firmware_fw.h" |
| 12 #include "rollback_index.h" | 10 #include "rollback_index.h" |
| 13 #include "utility.h" | 11 #include "utility.h" |
| 14 #include "vboot_common.h" | 12 #include "vboot_common.h" |
| 15 | 13 |
| 16 /* Static variables for UpdateFirmwareBodyHash(). It's less than | 14 /* Static variables for UpdateFirmwareBodyHash(). It's less than |
| 17 * optimal to have static variables in a library, but in UEFI the | 15 * optimal to have static variables in a library, but in UEFI the |
| 18 * caller is deep inside a different firmware stack and doesn't have a | 16 * caller is deep inside a different firmware stack and doesn't have a |
| 19 * good way to pass the params struct back to us. */ | 17 * good way to pass the params struct back to us. */ |
| 20 typedef struct VbLoadFirmwareInternal { | 18 typedef struct VbLoadFirmwareInternal { |
| 21 DigestContext body_digest_context; | 19 DigestContext body_digest_context; |
| 22 uint64_t body_size_accum; | 20 uint64_t body_size_accum; |
| 23 } VbLoadFirmwareInternal; | 21 } VbLoadFirmwareInternal; |
| 24 | 22 |
| 25 | 23 |
| 26 void UpdateFirmwareBodyHash(LoadFirmwareParams* params, | 24 void UpdateFirmwareBodyHash(LoadFirmwareParams* params, |
| 27 uint8_t* data, uint64_t size) { | 25 uint8_t* data, uint64_t size) { |
| 28 VbLoadFirmwareInternal* lfi = | 26 VbLoadFirmwareInternal* lfi = |
| 29 (VbLoadFirmwareInternal*)params->load_firmware_internal; | 27 (VbLoadFirmwareInternal*)params->load_firmware_internal; |
| 30 | 28 |
| 31 DigestUpdate(&lfi->body_digest_context, data, size); | 29 DigestUpdate(&lfi->body_digest_context, data, size); |
| 32 lfi->body_size_accum += size; | 30 lfi->body_size_accum += size; |
| 33 } | 31 } |
| 34 | 32 |
| 35 | 33 |
| 36 int LoadFirmware2(LoadFirmwareParams* params) { | 34 int LoadFirmware(LoadFirmwareParams* params) { |
| 37 | 35 |
| 38 VbPublicKey* root_key = (VbPublicKey*)params->firmware_root_key_blob; | 36 VbPublicKey* root_key = (VbPublicKey*)params->firmware_root_key_blob; |
| 39 VbLoadFirmwareInternal* lfi; | 37 VbLoadFirmwareInternal* lfi; |
| 40 | 38 |
| 41 uint16_t tpm_key_version = 0; | 39 uint16_t tpm_key_version = 0; |
| 42 uint16_t tpm_fw_version = 0; | 40 uint16_t tpm_fw_version = 0; |
| 43 uint64_t lowest_key_version = 0xFFFF; | 41 uint64_t lowest_key_version = 0xFFFF; |
| 44 uint64_t lowest_fw_version = 0xFFFF; | 42 uint64_t lowest_fw_version = 0xFFFF; |
| 45 int good_index = -1; | 43 int good_index = -1; |
| 46 int index; | 44 int index; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 /* Lock Firmware TPM rollback indices from further writes. In | 200 /* Lock Firmware TPM rollback indices from further writes. In |
| 203 * this design, this is done by setting the globalLock bit, which | 201 * this design, this is done by setting the globalLock bit, which |
| 204 * is cleared only by TPM_Init at reboot. */ | 202 * is cleared only by TPM_Init at reboot. */ |
| 205 if (0 != LockFirmwareVersions()) | 203 if (0 != LockFirmwareVersions()) |
| 206 return LOAD_FIRMWARE_RECOVERY; | 204 return LOAD_FIRMWARE_RECOVERY; |
| 207 } | 205 } |
| 208 | 206 |
| 209 /* If we're still here, no good firmware, so go to recovery mode. */ | 207 /* If we're still here, no good firmware, so go to recovery mode. */ |
| 210 return LOAD_FIRMWARE_RECOVERY; | 208 return LOAD_FIRMWARE_RECOVERY; |
| 211 } | 209 } |
| OLD | NEW |