| 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 * Developer file-signing utility | 5 * Developer file-signing utility |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 #include <getopt.h> | 9 #include <getopt.h> |
| 10 #include <inttypes.h> /* For PRIu64 */ | 10 #include <inttypes.h> /* For PRIu64 */ |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 Debug("Preamble is 0x%" PRIx64 " bytes\n", preamble->preamble_size); | 209 Debug("Preamble is 0x%" PRIx64 " bytes\n", preamble->preamble_size); |
| 210 current_buf_offset += preamble->preamble_size; | 210 current_buf_offset += preamble->preamble_size; |
| 211 if (current_buf_offset > buf_size ) { | 211 if (current_buf_offset > buf_size ) { |
| 212 error("preamble_size advances past the end of the buffer\n"); | 212 error("preamble_size advances past the end of the buffer\n"); |
| 213 return 1; | 213 return 1; |
| 214 } | 214 } |
| 215 | 215 |
| 216 Debug("Current buf offset is at 0x%" PRIx64 " bytes\n", current_buf_offset); | 216 Debug("Current buf offset is at 0x%" PRIx64 " bytes\n", current_buf_offset); |
| 217 | 217 |
| 218 /* Check the key block (hash only) */ | 218 /* Check the key block (hash only) */ |
| 219 if (0 != KeyBlockVerify(key_block, file_size, NULL, 1)) { | 219 if (0 != KeyBlockVerify(key_block, key_block->key_block_size, NULL, 1)) { |
| 220 error("Error verifying key block.\n"); | 220 error("Error verifying key block.\n"); |
| 221 return 1; | 221 return 1; |
| 222 } | 222 } |
| 223 | 223 |
| 224 printf("Key block:\n"); | 224 printf("Key block:\n"); |
| 225 data_key = &key_block->data_key; | 225 data_key = &key_block->data_key; |
| 226 printf(" Size: 0x%" PRIx64 "\n", key_block->key_block_size); | 226 printf(" Size: 0x%" PRIx64 "\n", key_block->key_block_size); |
| 227 printf(" Data key algorithm: %" PRIu64 " %s\n", data_key->algorithm, | 227 printf(" Data key algorithm: %" PRIu64 " %s\n", data_key->algorithm, |
| 228 (data_key->algorithm < kNumAlgorithms ? | 228 (data_key->algorithm < kNumAlgorithms ? |
| 229 algo_strings[data_key->algorithm] : "(invalid)")); | 229 algo_strings[data_key->algorithm] : "(invalid)")); |
| 230 printf(" Data key version: %" PRIu64 "\n", data_key->key_version); | 230 printf(" Data key version: %" PRIu64 "\n", data_key->key_version); |
| 231 printf(" Flags: %" PRIu64 "\n", key_block->key_block_flags); | 231 printf(" Flags: %" PRIu64 "\n", key_block->key_block_flags); |
| 232 | 232 |
| 233 | 233 |
| 234 /* Verify preamble */ | 234 /* Verify preamble */ |
| 235 rsa = PublicKeyToRSA(&key_block->data_key); | 235 rsa = PublicKeyToRSA(&key_block->data_key); |
| 236 if (!rsa) { | 236 if (!rsa) { |
| 237 error("Error parsing data key.\n"); | 237 error("Error parsing data key.\n"); |
| 238 return 1; | 238 return 1; |
| 239 } | 239 } |
| 240 if (0 != VerifyKernelPreamble(preamble, file_size, rsa)) { | 240 if (0 != VerifyKernelPreamble(preamble, preamble->preamble_size, rsa)) { |
| 241 error("Error verifying preamble.\n"); | 241 error("Error verifying preamble.\n"); |
| 242 return 1; | 242 return 1; |
| 243 } | 243 } |
| 244 | 244 |
| 245 printf("Preamble:\n"); | 245 printf("Preamble:\n"); |
| 246 printf(" Size: 0x%" PRIx64 "\n", preamble->preamble_size); | 246 printf(" Size: 0x%" PRIx64 "\n", preamble->preamble_size); |
| 247 printf(" Header version: %" PRIu32 ".%" PRIu32"\n", | 247 printf(" Header version: %" PRIu32 ".%" PRIu32"\n", |
| 248 preamble->header_version_major, preamble->header_version_minor); | 248 preamble->header_version_major, preamble->header_version_minor); |
| 249 printf(" Kernel version: %" PRIu64 "\n", preamble->kernel_version); | 249 printf(" Kernel version: %" PRIu64 "\n", preamble->kernel_version); |
| 250 printf(" Body load address: 0x%" PRIx64 "\n", preamble->body_load_address); | 250 printf(" Body load address: 0x%" PRIx64 "\n", preamble->body_load_address); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 346 |
| 347 default: | 347 default: |
| 348 fprintf(stderr, | 348 fprintf(stderr, |
| 349 "You must specify either --sign or --verify\n"); | 349 "You must specify either --sign or --verify\n"); |
| 350 return PrintHelp(progname); | 350 return PrintHelp(progname); |
| 351 } | 351 } |
| 352 | 352 |
| 353 /* NOTREACHED */ | 353 /* NOTREACHED */ |
| 354 return 1; | 354 return 1; |
| 355 } | 355 } |
| OLD | NEW |