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

Side by Side Diff: src/platform/vboot_reference/vkernel/kernel_image.c

Issue 2310002: Add a --subkey switch to kernel 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 unified diff | Download patch
« no previous file with comments | « src/platform/vboot_reference/vkernel/include/kernel_image.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 * 4 *
5 * Functions for generating and manipulating a verified boot kernel image. 5 * Functions for generating and manipulating a verified boot kernel image.
6 * (Userland portion) 6 * (Userland portion)
7 */ 7 */
8 #include "kernel_image.h" 8 #include "kernel_image.h"
9 9
10 #include <fcntl.h> 10 #include <fcntl.h>
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (st.overrun || st.remaining_len != 0) { /* Underrun or Overrun. */ 315 if (st.overrun || st.remaining_len != 0) { /* Underrun or Overrun. */
316 debug("GetKernelBlob() failed.\n"); 316 debug("GetKernelBlob() failed.\n");
317 Free(kernel_blob); 317 Free(kernel_blob);
318 return NULL; 318 return NULL;
319 } 319 }
320 return kernel_blob; 320 return kernel_blob;
321 } 321 }
322 322
323 int WriteKernelImage(const char* output_file, 323 int WriteKernelImage(const char* output_file,
324 const KernelImage* image, 324 const KernelImage* image,
325 int is_only_vblock) { 325 int is_only_vblock,
326 int is_subkey_out) {
326 int fd; 327 int fd;
327 int success = 1; 328 int success = 1;
328 uint8_t* kernel_blob; 329 uint8_t* kernel_blob = NULL;
330 uint8_t* subkey_out_buf = NULL;
331 uint8_t* subkey_header = NULL;
329 uint64_t blob_len; 332 uint64_t blob_len;
330 333
331 if (!image) 334 if (!image)
332 return 0; 335 return 0;
333 if (-1 == (fd = creat(output_file, S_IRWXU))) { 336 if (-1 == (fd = creat(output_file, S_IRWXU))) {
334 debug("Couldn't open file for writing kernel image: %s\n", 337 debug("Couldn't open file for writing kernel image: %s\n",
335 output_file); 338 output_file);
336 return 0; 339 return 0;
337 } 340 }
341 if (is_subkey_out) {
342 blob_len = GetKernelHeaderLen(image) +
343 siglen_map[image->firmware_sign_algorithm];
344 subkey_out_buf = (uint8_t*) Malloc(blob_len);
345 subkey_header = GetKernelHeaderBlob(image);
346 Memcpy(subkey_out_buf, subkey_header, GetKernelHeaderLen(image));
347 Memcpy(subkey_out_buf + GetKernelHeaderLen(image),
348 image->kernel_key_signature,
349 siglen_map[image->firmware_sign_algorithm]);
350 if (blob_len != write(fd, subkey_out_buf, blob_len)) {
351 debug("Couldn't write Kernel Subkey header to file: %s\n",
352 output_file);
353 success = 0;
354 }
355 Free(subkey_header);
356 Free(subkey_out_buf);
357 close(fd);
358 return success;
359 }
360
338 kernel_blob = GetKernelBlob(image, &blob_len); 361 kernel_blob = GetKernelBlob(image, &blob_len);
339 if (!kernel_blob) { 362 if (!kernel_blob) {
340 debug("Couldn't create kernel blob from KernelImage.\n"); 363 debug("Couldn't create kernel blob from KernelImage.\n");
341 return 0; 364 return 0;
342 } 365 }
343 if (!is_only_vblock) { 366 if (!is_only_vblock) {
344 if (blob_len != write(fd, kernel_blob, blob_len)) { 367 if (blob_len != write(fd, kernel_blob, blob_len)) {
345 debug("Couldn't write Kernel Image to file: %s\n", 368 debug("Couldn't write Kernel Image to file: %s\n",
346 output_file); 369 output_file);
347 success = 0; 370 success = 0;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 // Clean up and return the blob. 746 // Clean up and return the blob.
724 done3: 747 done3:
725 Free(bootloader_buf); 748 Free(bootloader_buf);
726 done2: 749 done2:
727 Free(config_buf); 750 Free(config_buf);
728 done1: 751 done1:
729 Free(kernel_buf); 752 Free(kernel_buf);
730 done0: 753 done0:
731 return blob; 754 return blob;
732 } 755 }
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/vkernel/include/kernel_image.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698