| 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  * Functions for verifying a verified boot firmware image. | 5  * Functions for verifying a verified boot firmware image. | 
| 6  * (Firmware Portion) | 6  * (Firmware Portion) | 
| 7  */ | 7  */ | 
| 8 | 8 | 
| 9 #include "firmware_image_fw.h" | 9 #include "firmware_image_fw.h" | 
| 10 | 10 | 
| 11 #include "cryptolib.h" | 11 #include "cryptolib.h" | 
| 12 #include "rollback_index.h" | 12 #include "rollback_index.h" | 
|  | 13 #include "tss_constants.h" | 
| 13 #include "utility.h" | 14 #include "utility.h" | 
| 14 | 15 | 
| 15 /* Macro to determine the size of a field structure in the FirmwareImage | 16 /* Macro to determine the size of a field structure in the FirmwareImage | 
| 16  * structure. */ | 17  * structure. */ | 
| 17 #define FIELD_LEN(field) (sizeof(((FirmwareImage*)0)->field)) | 18 #define FIELD_LEN(field) (sizeof(((FirmwareImage*)0)->field)) | 
| 18 | 19 | 
| 19 char* kVerifyFirmwareErrors[VERIFY_FIRMWARE_MAX] = { | 20 char* kVerifyFirmwareErrors[VERIFY_FIRMWARE_MAX] = { | 
| 20   "Success.", | 21   "Success.", | 
| 21   "Invalid Image.", | 22   "Invalid Image.", | 
| 22   "Root Key Signature Failed.", | 23   "Root Key Signature Failed.", | 
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 303                             (uint16_t) (min_lversion & 0xFFFF)); | 304                             (uint16_t) (min_lversion & 0xFFFF)); | 
| 304         stored_lversion = min_lversion;  /* Update stored version as it's used | 305         stored_lversion = min_lversion;  /* Update stored version as it's used | 
| 305                                           * later. */ | 306                                           * later. */ | 
| 306       } | 307       } | 
| 307     } | 308     } | 
| 308   } | 309   } | 
| 309   /* Lock Firmware TPM rollback indices from further writes.  In this design, | 310   /* Lock Firmware TPM rollback indices from further writes.  In this design, | 
| 310    * this is done by setting the globalLock bit, which is cleared only by | 311    * this is done by setting the globalLock bit, which is cleared only by | 
| 311    * TPM_Init at reboot. | 312    * TPM_Init at reboot. | 
| 312    */ | 313    */ | 
| 313   LockFirmwareVersions(); | 314   if (TPM_SUCCESS != LockFirmwareVersions()) { | 
|  | 315     return VERIFY_FIRMWARE_TPM_ERROR; | 
|  | 316   } | 
| 314 | 317 | 
| 315   /* Determine which firmware (if any) to jump to. | 318   /* Determine which firmware (if any) to jump to. | 
| 316    * | 319    * | 
| 317    * We always attempt to jump to FirmwareA first. If verification of FirmwareA | 320    * We always attempt to jump to FirmwareA first. If verification of FirmwareA | 
| 318    * fails, we try FirmwareB. In all cases, if the firmware successfully | 321    * fails, we try FirmwareB. In all cases, if the firmware successfully | 
| 319    * verified but is a rollback, we jump to recovery. | 322    * verified but is a rollback, we jump to recovery. | 
| 320    * | 323    * | 
| 321    * Note: This means that if FirmwareA verified successfully and is a | 324    * Note: This means that if FirmwareA verified successfully and is a | 
| 322    * rollback, then no attempt is made to check FirmwareB. We still jump to | 325    * rollback, then no attempt is made to check FirmwareB. We still jump to | 
| 323    * recovery. FirmwareB is only used as a backup in case FirmwareA gets | 326    * recovery. FirmwareB is only used as a backup in case FirmwareA gets | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 336      */ | 339      */ | 
| 337     if (stored_lversion <= firmwareB_lversion && | 340     if (stored_lversion <= firmwareB_lversion && | 
| 338         (VERIFY_FIRMWARE_SUCCESS == VerifyFirmware(root_key_blob, | 341         (VERIFY_FIRMWARE_SUCCESS == VerifyFirmware(root_key_blob, | 
| 339                                                    verification_headerB, | 342                                                    verification_headerB, | 
| 340                                                    firmwareB))) | 343                                                    firmwareB))) | 
| 341         return BOOT_FIRMWARE_B_CONTINUE; | 344         return BOOT_FIRMWARE_B_CONTINUE; | 
| 342   } | 345   } | 
| 343   /* D'oh: No bootable firmware. */ | 346   /* D'oh: No bootable firmware. */ | 
| 344   return BOOT_FIRMWARE_RECOVERY_CONTINUE; | 347   return BOOT_FIRMWARE_RECOVERY_CONTINUE; | 
| 345 } | 348 } | 
| OLD | NEW | 
|---|