Vboot Reference: Make kernel signing utility more flexible.
The CL adds the --config and --vblock option to kernel_utility.
--config <file> uses the file to populate the configuration portion within a signed vbootimage
Currently, the configuration file is assumed to only contain command line options to be passed to the kernel. In the future, we might want to change it so that it contains information about the kernel load address, entry points, etc. (refer to rspangler@ drive map design doc)
--vblock makes the tool only output the verification header instead of a one monolithic signed kernel image containing the verification information (with config information contained within it) followed by the actual kernel image
Review URL: http://codereview.chromium.org/1752013
diff --git a/vkernel/kernel_image.c b/vkernel/kernel_image.c
index 8c8c092..cc18467 100644
--- a/vkernel/kernel_image.c
+++ b/vkernel/kernel_image.c
@@ -29,6 +29,7 @@
if (image) {
image->kernel_sign_key = NULL;
image->kernel_key_signature = NULL;
+ Memset(image->options.cmd_line, 0, sizeof(image->options.cmd_line));
image->config_signature = NULL;
image->kernel_signature = NULL;
image->kernel_data = NULL;
@@ -298,8 +299,10 @@
}
int WriteKernelImage(const char* input_file,
- const KernelImage* image) {
+ const KernelImage* image,
+ int is_only_vblock) {
int fd;
+ int success = 1;
uint8_t* kernel_blob;
uint64_t blob_len;
@@ -315,17 +318,24 @@
debug("Couldn't create kernel blob from KernelImage.\n");
return 0;
}
- if (blob_len != write(fd, kernel_blob, blob_len)) {
- debug("Couldn't write Kernel Image to file: %s\n",
+ if (!is_only_vblock) {
+ if (blob_len != write(fd, kernel_blob, blob_len)) {
+ debug("Couldn't write Kernel Image to file: %s\n",
input_file);
-
- Free(kernel_blob);
- close(fd);
- return 0;
+ success = 0;
+ }
+ } else {
+ /* Exclude the kernel_data. */
+ int vblock_len = blob_len - image->options.kernel_len;
+ if (vblock_len != write(fd, kernel_blob, vblock_len)) {
+ debug("Couldn't write Kernel Image Verification block to file: %s\n",
+ input_file);
+ success = 0;
+ }
}
Free(kernel_blob);
close(fd);
- return 1;
+ return success;
}
void PrintKernelImage(const KernelImage* image) {