| 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 * Utility for aiding fuzz testing of firmware image verification code. | 5 * Utility for aiding fuzz testing of firmware image verification code. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 | 9 |
| 10 #include "file_keys.h" | 10 #include "file_keys.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 if (!root_key_blob) { | 21 if (!root_key_blob) { |
| 22 fprintf(stderr, "Couldn't read pre-processed public root key.\n"); | 22 fprintf(stderr, "Couldn't read pre-processed public root key.\n"); |
| 23 error_code = 1; | 23 error_code = 1; |
| 24 } | 24 } |
| 25 | 25 |
| 26 if (!error_code && !firmware_blob) { | 26 if (!error_code && !firmware_blob) { |
| 27 fprintf(stderr, "Couldn't read firmware image or malformed image.\n"); | 27 fprintf(stderr, "Couldn't read firmware image or malformed image.\n"); |
| 28 error_code = 1; | 28 error_code = 1; |
| 29 } | 29 } |
| 30 | 30 |
| 31 if (!error_code && (error = VerifyFirmware(root_key_blob, firmware_blob, | 31 if (!error_code && (error = VerifyFirmware(root_key_blob, firmware_blob))) { |
| 32 0))) { /* Trusted Mode. */ | |
| 33 fprintf(stderr, "%s\n", VerifyFirmwareErrorString(error)); | 32 fprintf(stderr, "%s\n", VerifyFirmwareErrorString(error)); |
| 34 error_code = 1; | 33 error_code = 1; |
| 35 } | 34 } |
| 36 Free(root_key_blob); | 35 Free(root_key_blob); |
| 37 Free(firmware_blob); | 36 Free(firmware_blob); |
| 38 if (error_code) | 37 if (error_code) |
| 39 return 0; | 38 return 0; |
| 40 else | 39 else |
| 41 return 1; | 40 return 1; |
| 42 } | 41 } |
| 43 | 42 |
| 44 int main(int argc, char* argv[]) { | 43 int main(int argc, char* argv[]) { |
| 45 if (argc != 3) { | 44 if (argc != 3) { |
| 46 fprintf(stderr, "Usage: %s <image_to_verify> <root_keyb>\n", argv[0]); | 45 fprintf(stderr, "Usage: %s <image_to_verify> <root_keyb>\n", argv[0]); |
| 47 return -1; | 46 return -1; |
| 48 } | 47 } |
| 49 if (VerifySignedFirmware(argv[1], argv[2])) { | 48 if (VerifySignedFirmware(argv[1], argv[2])) { |
| 50 fprintf(stderr, "Verification SUCCESS!\n"); | 49 fprintf(stderr, "Verification SUCCESS!\n"); |
| 51 return 0; | 50 return 0; |
| 52 } | 51 } |
| 53 else { | 52 else { |
| 54 fprintf(stderr, "Verification FAILURE!\n"); | 53 fprintf(stderr, "Verification FAILURE!\n"); |
| 55 return -1; | 54 return -1; |
| 56 } | 55 } |
| 57 } | 56 } |
| OLD | NEW |