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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 int main(int argc, char* argv[]) { | 75 int main(int argc, char* argv[]) { |
76 | 76 |
77 const char* image_name; | 77 const char* image_name; |
78 const char* keyfile_name; | 78 const char* keyfile_name; |
79 int rv; | 79 int rv; |
80 | 80 |
81 Memset(&lkp, 0, sizeof(LoadKernelParams)); | 81 Memset(&lkp, 0, sizeof(LoadKernelParams)); |
82 lkp.bytes_per_lba = LBA_BYTES; | 82 lkp.bytes_per_lba = LBA_BYTES; |
83 | 83 |
84 /* Read command line parameters */ | 84 /* Read command line parameters */ |
85 if (4 > argc) { | 85 if (3 > argc) { |
86 fprintf(stderr, "usage: %s <drive_image> <sign_key> [boot flag]\n", argv[0]) ; | 86 fprintf(stderr, "usage: %s <drive_image> <sign_key> [boot flag]\n", argv[0]) ; |
87 return 1; | 87 return 1; |
88 } | 88 } |
89 image_name = argv[1]; | 89 image_name = argv[1]; |
90 keyfile_name = argv[2]; | 90 keyfile_name = argv[2]; |
91 | 91 |
92 /* Read header signing key blob */ | 92 /* Read header signing key blob */ |
93 { | 93 { |
94 uint64_t key_size; | 94 uint64_t key_size; |
95 lkp.header_sign_key_blob = ReadFile(keyfile_name, &key_size); | 95 lkp.header_sign_key_blob = ReadFile(keyfile_name, &key_size); |
(...skipping 17 matching lines...) Expand all Loading... | |
113 | 113 |
114 /* Allocate a buffer for the kernel */ | 114 /* Allocate a buffer for the kernel */ |
115 lkp.kernel_buffer = Malloc(KERNEL_BUFFER_SIZE); | 115 lkp.kernel_buffer = Malloc(KERNEL_BUFFER_SIZE); |
116 if(!lkp.kernel_buffer) { | 116 if(!lkp.kernel_buffer) { |
117 fprintf(stderr, "Unable to allocate kernel buffer.\n"); | 117 fprintf(stderr, "Unable to allocate kernel buffer.\n"); |
118 return 1; | 118 return 1; |
119 } | 119 } |
120 | 120 |
121 /* Need to skip the address check, since we're putting it somewhere on the | 121 /* Need to skip the address check, since we're putting it somewhere on the |
122 * heap instead of its actual target address in the firmware. */ | 122 * heap instead of its actual target address in the firmware. */ |
123 if (argc == 4) { | 123 if (argc == 4) { |
Randall Spangler
2010/07/10 00:09:42
Might make this >=4, so it'll work if we add a 5th
| |
124 lkp.boot_flags = atoi(argv[3]) | BOOT_FLAG_SKIP_ADDR_CHECK; | 124 lkp.boot_flags = atoi(argv[3]) | BOOT_FLAG_SKIP_ADDR_CHECK; |
125 } else { | 125 } else { |
126 /* Default to recovery. */ | 126 /* Default to recovery. */ |
127 lkp.boot_flags = BOOT_FLAG_SKIP_ADDR_CHECK | BOOT_FLAG_RECOVERY; | 127 lkp.boot_flags = BOOT_FLAG_SKIP_ADDR_CHECK | BOOT_FLAG_RECOVERY; |
128 } | 128 } |
129 /* Call LoadKernel() */ | 129 /* Call LoadKernel() */ |
130 rv = LoadKernel(&lkp); | 130 rv = LoadKernel(&lkp); |
131 printf("LoadKernel() returned %d\n", rv); | 131 printf("LoadKernel() returned %d\n", rv); |
132 | 132 |
133 if (LOAD_KERNEL_SUCCESS == rv) { | 133 if (LOAD_KERNEL_SUCCESS == rv) { |
134 printf("Partition number: %" PRIu64 "\n", lkp.partition_number); | 134 printf("Partition number: %" PRIu64 "\n", lkp.partition_number); |
135 printf("Bootloader address: %" PRIu64 "\n", lkp.bootloader_address); | 135 printf("Bootloader address: %" PRIu64 "\n", lkp.bootloader_address); |
136 printf("Bootloader size: %" PRIu64 "\n", lkp.bootloader_size); | 136 printf("Bootloader size: %" PRIu64 "\n", lkp.bootloader_size); |
137 } | 137 } |
138 | 138 |
139 fclose(image_file); | 139 fclose(image_file); |
140 Free(lkp.kernel_buffer); | 140 Free(lkp.kernel_buffer); |
141 return rv != LOAD_KERNEL_SUCCESS; | 141 return rv != LOAD_KERNEL_SUCCESS; |
142 } | 142 } |
OLD | NEW |