| 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 | 5 |
| 6 /* Routines for verifying a file's signature. Useful in testing the core | 6 /* Routines for verifying a file's signature. Useful in testing the core |
| 7 * RSA verification implementation. | 7 * RSA verification implementation. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #include <inttypes.h> /* For PRIu64 macro */ | 10 #include <inttypes.h> /* For PRIu64 macro */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 fprintf(stderr, "usage: %s <drive_image> <sign_key>\n", argv[0]); | 91 fprintf(stderr, "usage: %s <drive_image> <sign_key>\n", argv[0]); |
| 92 return 1; | 92 return 1; |
| 93 } | 93 } |
| 94 image_name = argv[1]; | 94 image_name = argv[1]; |
| 95 keyfile_name = argv[2]; | 95 keyfile_name = argv[2]; |
| 96 | 96 |
| 97 /* Read header signing key blob */ | 97 /* Read header signing key blob */ |
| 98 { | 98 { |
| 99 uint64_t key_size; | 99 uint64_t key_size; |
| 100 lkp.header_sign_key_blob = ReadFile(keyfile_name, &key_size); | 100 lkp.header_sign_key_blob = ReadFile(keyfile_name, &key_size); |
| 101 if (!lkp.header_sign_key_blob) | 101 if (!lkp.header_sign_key_blob) { |
| 102 fprintf(stderr, "Unable to read key file %s\n", keyfile_name); | 102 fprintf(stderr, "Unable to read key file %s\n", keyfile_name); |
| 103 return 1; | 103 return 1; |
| 104 } | 104 } |
| 105 } |
| 105 | 106 |
| 106 /* Get image size */ | 107 /* Get image size */ |
| 107 printf("Reading from image: %s\n", image_name); | 108 printf("Reading from image: %s\n", image_name); |
| 108 image_file = fopen(image_name, "rb"); | 109 image_file = fopen(image_name, "rb"); |
| 109 if (!image_file) { | 110 if (!image_file) { |
| 110 fprintf(stderr, "Unable to open image file %s\n", image_name); | 111 fprintf(stderr, "Unable to open image file %s\n", image_name); |
| 111 return 1; | 112 return 1; |
| 112 } | 113 } |
| 113 fseek(image_file, 0, SEEK_END); | 114 fseek(image_file, 0, SEEK_END); |
| 114 lkp.ending_lba = (ftell(image_file) / LBA_BYTES) - 1; | 115 lkp.ending_lba = (ftell(image_file) / LBA_BYTES) - 1; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 132 if (LOAD_KERNEL_SUCCESS == rv) { | 133 if (LOAD_KERNEL_SUCCESS == rv) { |
| 133 printf("Partition number: %" PRIu64 "\n", lkp.partition_number); | 134 printf("Partition number: %" PRIu64 "\n", lkp.partition_number); |
| 134 printf("Bootloader address: %" PRIu64 "\n", lkp.bootloader_address); | 135 printf("Bootloader address: %" PRIu64 "\n", lkp.bootloader_address); |
| 135 printf("Bootloader size: %" PRIu64 "\n", lkp.bootloader_size); | 136 printf("Bootloader size: %" PRIu64 "\n", lkp.bootloader_size); |
| 136 } | 137 } |
| 137 | 138 |
| 138 fclose(image_file); | 139 fclose(image_file); |
| 139 Free(lkp.kernel_buffer); | 140 Free(lkp.kernel_buffer); |
| 140 return 0; | 141 return 0; |
| 141 } | 142 } |
| OLD | NEW |