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

Unified Diff: src/platform/vboot_reference/tests/verify_firmware_fuzz_driver.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/verify_firmware_fuzz_driver.c
diff --git a/src/platform/vboot_reference/tests/verify_firmware_fuzz_driver.c b/src/platform/vboot_reference/tests/verify_firmware_fuzz_driver.c
index 8ab33ad685c0f9cd8cd1221880a54600241fc64d..f04a7d5da8e27bae348bea40a508a5c0c2a6c19e 100644
--- a/src/platform/vboot_reference/tests/verify_firmware_fuzz_driver.c
+++ b/src/platform/vboot_reference/tests/verify_firmware_fuzz_driver.c
@@ -11,11 +11,13 @@
#include "firmware_image.h"
#include "utility.h"
-int VerifySignedFirmware(const char* image_file,
- const char* root_key_file) {
+int VerifySignedFirmware(const char* root_key_file,
+ const char* verification_file,
+ const char* firmware_file) {
int error, error_code = 0;
uint64_t len;
- uint8_t* firmware_blob = BufferFromFile(image_file, &len);
+ uint8_t* verification_blob = BufferFromFile(verification_file, &len);
+ uint8_t* firmware_blob = BufferFromFile(firmware_file, &len);
uint8_t* root_key_blob = BufferFromFile(root_key_file, &len);
if (!root_key_blob) {
@@ -24,11 +26,18 @@ int VerifySignedFirmware(const char* image_file,
}
if (!error_code && !firmware_blob) {
- fprintf(stderr, "Couldn't read firmware image or malformed image.\n");
+ fprintf(stderr, "Couldn't read firmware image.\n");
error_code = 1;
}
- if (!error_code && (error = VerifyFirmware(root_key_blob, firmware_blob))) {
+ if (!error_code && !verification_blob) {
+ fprintf(stderr, "Couldn't read verification data image.\n");
+ error_code = 1;
+ }
+
+ if (!error_code && (error = VerifyFirmware(root_key_blob,
+ verification_blob,
+ firmware_blob))) {
fprintf(stderr, "%s\n", VerifyFirmwareErrorString(error));
error_code = 1;
}
@@ -41,15 +50,15 @@ int VerifySignedFirmware(const char* image_file,
}
int main(int argc, char* argv[]) {
- if (argc != 3) {
- fprintf(stderr, "Usage: %s <image_to_verify> <root_keyb>\n", argv[0]);
+ if (argc != 4) {
+ fprintf(stderr, "Usage: %s <verification blob> <image_to_verify> <root_keyb>"
+ "\n", argv[0]);
return -1;
}
- if (VerifySignedFirmware(argv[1], argv[2])) {
+ if (VerifySignedFirmware(argv[3], argv[1], argv[2])) {
fprintf(stderr, "Verification SUCCESS!\n");
return 0;
- }
- else {
+ } else {
fprintf(stderr, "Verification FAILURE!\n");
return -1;
}
« no previous file with comments | « src/platform/vboot_reference/tests/test_common.c ('k') | src/platform/vboot_reference/vfirmware/firmware_image_fw.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698