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

Unified Diff: src/platform/vboot_reference/tests/firmware_rollback_tests.c

Issue 1578035: Change VerifyFirmware() to take separate pointers to firmware verification header and firmware data. (Closed)
Patch Set: review fixes Created 10 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: src/platform/vboot_reference/tests/firmware_rollback_tests.c
diff --git a/src/platform/vboot_reference/tests/firmware_rollback_tests.c b/src/platform/vboot_reference/tests/firmware_rollback_tests.c
index 3608db737fd87775f4ebad786815f226f3327b53..14c0475c3224ec72f5946d61eb315575b5d672df 100644
--- a/src/platform/vboot_reference/tests/firmware_rollback_tests.c
+++ b/src/platform/vboot_reference/tests/firmware_rollback_tests.c
@@ -16,14 +16,14 @@
#include "test_common.h"
const char* kRootKeyPublicFile = "testkeys/key_rsa8192.keyb";
+uint8_t kValidFirmwareData[1] = { 'F' };
+uint8_t kCorruptFirmwareData[1] = { 'X' };
/* Tests that check for correctness of the VerifyFirmwareDriver_f() logic
* and rollback prevention. */
void VerifyFirmwareDriverTest(void) {
- uint8_t* valid_firmwareA = NULL;
- uint8_t* valid_firmwareB = NULL;
- uint8_t* corrupt_firmwareA = NULL;
- uint8_t* corrupt_firmwareB = NULL;
+ uint8_t* verification_blobA = NULL;
+ uint8_t* verification_blobB = NULL;
uint64_t len;
uint8_t* root_key_pub = BufferFromFile(kRootKeyPublicFile, &len);
@@ -31,43 +31,55 @@ void VerifyFirmwareDriverTest(void) {
g_firmware_key_version = 1;
g_firmware_version = 1;
- valid_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 0);
- valid_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 0);
- corrupt_firmwareA = GenerateRollbackTestFirmwareBlob(1, 1, 1);
- corrupt_firmwareB = GenerateRollbackTestFirmwareBlob(1, 1, 1);
+ verification_blobA = GenerateRollbackTestVerificationBlob(1, 1);
+ verification_blobB = GenerateRollbackTestVerificationBlob(1, 1);
TEST_EQ(VerifyFirmwareDriver_f(root_key_pub,
- valid_firmwareA, valid_firmwareB),
+ verification_blobA,
+ kValidFirmwareData,
+ verification_blobB,
+ kValidFirmwareData),
BOOT_FIRMWARE_A_CONTINUE,
"Firmware A (Valid with current version), "
"Firmware B (Valid with current version)");
TEST_EQ(VerifyFirmwareDriver_f(root_key_pub,
- corrupt_firmwareA, valid_firmwareB),
+ verification_blobA,
+ kCorruptFirmwareData,
+ verification_blobB,
+ kValidFirmwareData),
BOOT_FIRMWARE_B_CONTINUE,
"Firmware A (Corrupt with current version), "
- "FirmwareB (Valid with current version)");
+ "Firmware B (Valid with current version)");
TEST_EQ(VerifyFirmwareDriver_f(root_key_pub,
- valid_firmwareA, corrupt_firmwareB),
+ verification_blobA,
+ kValidFirmwareData,
+ verification_blobB,
+ kCorruptFirmwareData),
BOOT_FIRMWARE_A_CONTINUE,
"Firmware A (Valid with current version), "
- "FirmwareB (Corrupt with current version)");
+ "Firmware B (Corrupt with current version)");
TEST_EQ(VerifyFirmwareDriver_f(root_key_pub,
- corrupt_firmwareA, corrupt_firmwareB),
+ verification_blobA,
+ kCorruptFirmwareData,
+ verification_blobB,
+ kCorruptFirmwareData),
BOOT_FIRMWARE_RECOVERY_CONTINUE,
"Firmware A (Corrupt with current version), "
- "FirmwareB (Corrupt with current version");
+ "Firmware B (Corrupt with current version");
g_firmware_key_version = 2;
g_firmware_version = 2;
- TEST_EQ(VerifyFirmwareDriver_f(root_key_pub, valid_firmwareA, valid_firmwareB),
+ TEST_EQ(VerifyFirmwareDriver_f(root_key_pub,
+ verification_blobA,
+ kValidFirmwareData,
+ verification_blobB,
+ kValidFirmwareData),
BOOT_FIRMWARE_RECOVERY_CONTINUE,
"Firmware A (Valid with old version), "
"Old Firmware B (Valid with old version)");
Free(root_key_pub);
- Free(valid_firmwareA);
- Free(valid_firmwareB);
- Free(corrupt_firmwareA);
- Free(corrupt_firmwareB);
+ Free(verification_blobA);
+ Free(verification_blobB);
}
int main(int argc, char* argv[]) {

Powered by Google App Engine
This is Rietveld 408576698