mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 02:35:22 +00:00
This CL adds a new function VerifyFirmwareDriver_f() means to be a part of the RO firmware which determine which copy of the firmware to boot from. It is meant to ensure that a particular firmware is only booted if 1) it verifies successfully, 2) its version is newer or equal to current stored version. In addition, the driver function also updates the stored version if needed. Currently I am using the TLCL API with stub calls, (in fact, most of the TPM interaction is done in rollback_index.c which implements the actual version query/update API) used by the firmware. Review URL: http://codereview.chromium.org/1241002
62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*
|
|
* Mock rollback index library for testing.
|
|
*/
|
|
|
|
#include "rollback_index.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
|
|
uint16_t g_firmware_key_version = 0;
|
|
uint16_t g_firmware_version = 0;
|
|
uint16_t g_kernel_key_version = 0;
|
|
uint16_t g_kernel_version = 0;
|
|
|
|
void SetupTPM(void) {
|
|
fprintf(stderr, "Rollback Index Library Mock: TPM initialized.\n");
|
|
}
|
|
|
|
uint16_t GetStoredVersion(int type) {
|
|
switch (type) {
|
|
case FIRMWARE_KEY_VERSION:
|
|
return g_firmware_key_version;
|
|
break;
|
|
case FIRMWARE_VERSION:
|
|
return g_firmware_version;
|
|
break;
|
|
case KERNEL_KEY_VERSION:
|
|
return g_kernel_key_version;
|
|
break;
|
|
case KERNEL_VERSION:
|
|
return g_kernel_version;
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int WriteStoredVersion(int type, uint16_t version) {
|
|
switch (type) {
|
|
case FIRMWARE_KEY_VERSION:
|
|
g_firmware_key_version = version;
|
|
break;
|
|
case FIRMWARE_VERSION:
|
|
g_firmware_version = version;
|
|
break;
|
|
case KERNEL_KEY_VERSION:
|
|
g_kernel_key_version = version;
|
|
break;
|
|
case KERNEL_VERSION:
|
|
g_kernel_version = version;
|
|
break;
|
|
}
|
|
fprintf(stderr, "Rollback Index Library Mock: Stored Version written.\n");
|
|
return 1;
|
|
}
|
|
|
|
void LockStoredVersion(int type) {
|
|
fprintf(stderr, "Rollback Index Library Mock: Version Locked.\n");
|
|
}
|