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

Unified Diff: src/platform/vboot_reference/vfirmware/firmware_image.c

Issue 2366004: Add --subkey_in and --subkey_out options to firmware signing utility. (Closed) Base URL: ssh://git@gitrw.chromium.org/chromiumos
Patch Set: Created 10 years, 7 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/vfirmware/firmware_image.c
diff --git a/src/platform/vboot_reference/vfirmware/firmware_image.c b/src/platform/vboot_reference/vfirmware/firmware_image.c
index ba55d0a18f00fe21d5a941a09f4cc4a65ad4f29f..d16a1fc70bca9699c6a88fc5370705f9b20f7fd7 100644
--- a/src/platform/vboot_reference/vfirmware/firmware_image.c
+++ b/src/platform/vboot_reference/vfirmware/firmware_image.c
@@ -259,10 +259,13 @@ uint8_t* GetFirmwareBlob(const FirmwareImage* image, uint64_t* blob_len) {
int WriteFirmwareImage(const char* output_file,
const FirmwareImage* image,
- int is_only_vblock) {
+ int is_only_vblock,
+ int is_subkey_out) {
int fd;
int success = 1;
uint8_t* firmware_blob;
+ uint8_t* subkey_out_buf = NULL;
+ uint8_t* subkey_header = NULL;
uint64_t blob_len;
if (!image)
@@ -271,6 +274,25 @@ int WriteFirmwareImage(const char* output_file,
debug("Couldn't open file for writing.\n");
return 0;
}
+ if (is_subkey_out) {
+ blob_len = GetFirmwareHeaderLen(image) +
+ siglen_map[ROOT_SIGNATURE_ALGORITHM];
+ subkey_out_buf = (uint8_t*) Malloc(blob_len);
+ subkey_header = GetFirmwareHeaderBlob(image);
+ Memcpy(subkey_out_buf, subkey_header, GetFirmwareHeaderLen(image));
+ Memcpy(subkey_out_buf + GetFirmwareHeaderLen(image),
+ image->firmware_key_signature,
+ siglen_map[ROOT_SIGNATURE_ALGORITHM]);
+ if (blob_len != write(fd, subkey_out_buf, blob_len)) {
+ debug("Couldn't write kernel subkey header to file: %s\n",
+ output_file);
+ success = 0;
+ }
+ Free(subkey_header);
+ Free(subkey_out_buf);
+ close(fd);
+ return success;
+ }
firmware_blob = GetFirmwareBlob(image, &blob_len);
if (!firmware_blob) {

Powered by Google App Engine
This is Rietveld 408576698