| OLD | NEW |
| 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 */ | 6 */ |
| 7 | 7 |
| 8 #include "kernel_image.h" | 8 #include "kernel_image.h" |
| 9 | 9 |
| 10 #include <fcntl.h> | 10 #include <fcntl.h> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 Free(image->kernel_sign_key); | 41 Free(image->kernel_sign_key); |
| 42 Free(image->kernel_key_signature); | 42 Free(image->kernel_key_signature); |
| 43 Free(image->config_signature); | 43 Free(image->config_signature); |
| 44 Free(image->kernel_signature); | 44 Free(image->kernel_signature); |
| 45 Free(image->kernel_data); | 45 Free(image->kernel_data); |
| 46 Free(image); | 46 Free(image); |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 | 49 |
| 50 KernelImage* ReadKernelImage(const char* input_file) { | 50 KernelImage* ReadKernelImage(const char* input_file) { |
| 51 uint32_t file_size; | 51 uint64_t file_size; |
| 52 int image_len = 0; /* Total size of the kernel image. */ | 52 int image_len = 0; /* Total size of the kernel image. */ |
| 53 int header_len = 0; | 53 int header_len = 0; |
| 54 int firmware_sign_key_len; | 54 int firmware_sign_key_len; |
| 55 int kernel_key_signature_len; | 55 int kernel_key_signature_len; |
| 56 int kernel_sign_key_len; | 56 int kernel_sign_key_len; |
| 57 int kernel_signature_len; | 57 int kernel_signature_len; |
| 58 uint8_t* kernel_buf; | 58 uint8_t* kernel_buf; |
| 59 MemcpyState st; | 59 MemcpyState st; |
| 60 KernelImage* image = KernelImageNew(); | 60 KernelImage* image = KernelImageNew(); |
| 61 | 61 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 "Kernel Key Version = %d\n\n", | 307 "Kernel Key Version = %d\n\n", |
| 308 image->header_len, | 308 image->header_len, |
| 309 image->firmware_sign_algorithm, | 309 image->firmware_sign_algorithm, |
| 310 image->kernel_sign_algorithm, | 310 image->kernel_sign_algorithm, |
| 311 algo_strings[image->kernel_sign_algorithm], | 311 algo_strings[image->kernel_sign_algorithm], |
| 312 image->kernel_key_version); | 312 image->kernel_key_version); |
| 313 /* TODO(gauravsh): Output hash and key signature here? */ | 313 /* TODO(gauravsh): Output hash and key signature here? */ |
| 314 /* Print preamble. */ | 314 /* Print preamble. */ |
| 315 printf("Kernel Version = %d\n" | 315 printf("Kernel Version = %d\n" |
| 316 "Kernel Config Version = %d.%d\n" | 316 "Kernel Config Version = %d.%d\n" |
| 317 "kernel Length = %d\n" | 317 "kernel Length = %" PRId64 "\n" |
| 318 "Kernel Load Address = %" PRId64 "\n" | 318 "Kernel Load Address = %" PRId64 "\n" |
| 319 "Kernel Entry Address = %" PRId64 "\n\n", | 319 "Kernel Entry Address = %" PRId64 "\n\n", |
| 320 image->kernel_version, | 320 image->kernel_version, |
| 321 image->options.version[0], image->options.version[1], | 321 image->options.version[0], image->options.version[1], |
| 322 image->options.kernel_len, | 322 image->options.kernel_len, |
| 323 image->options.kernel_load_addr, | 323 image->options.kernel_load_addr, |
| 324 image->options.kernel_entry_addr); | 324 image->options.kernel_entry_addr); |
| 325 /* TODO(gauravsh): Output kernel signature here? */ | 325 /* TODO(gauravsh): Output kernel signature here? */ |
| 326 } | 326 } |
| 327 | 327 |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 kernel_signing_key_file, | 669 kernel_signing_key_file, |
| 670 image->kernel_sign_algorithm))) { | 670 image->kernel_sign_algorithm))) { |
| 671 fprintf(stderr, "Could not compute signature on the kernel.\n"); | 671 fprintf(stderr, "Could not compute signature on the kernel.\n"); |
| 672 return 0; | 672 return 0; |
| 673 } | 673 } |
| 674 image->kernel_signature = (uint8_t*) Malloc(signature_len); | 674 image->kernel_signature = (uint8_t*) Malloc(signature_len); |
| 675 Memcpy(image->kernel_signature, kernel_signature, signature_len); | 675 Memcpy(image->kernel_signature, kernel_signature, signature_len); |
| 676 Free(kernel_signature); | 676 Free(kernel_signature); |
| 677 return 1; | 677 return 1; |
| 678 } | 678 } |
| OLD | NEW |