| 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 | 6 |
| 7 #ifndef VBOOT_REFERENCE_TEST_COMMON_H_ | 7 #ifndef VBOOT_REFERENCE_TEST_COMMON_H_ |
| 8 #define VBOOT_REFERENCE_TEST_COMMON_H_ | 8 #define VBOOT_REFERENCE_TEST_COMMON_H_ |
| 9 | 9 |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include "firmware_image.h" | |
| 13 #include "kernel_image.h" | 12 #include "kernel_image.h" |
| 14 | 13 |
| 15 extern int gTestSuccess; | 14 extern int gTestSuccess; |
| 16 | 15 |
| 17 /* Return 1 if result is equal to expected_result, else return 0. | 16 /* Return 1 if result is equal to expected_result, else return 0. |
| 18 * Also update the global gTestSuccess flag if test fails. */ | 17 * Also update the global gTestSuccess flag if test fails. */ |
| 19 int TEST_EQ(int result, int expected_result, char* testname); | 18 int TEST_EQ(int result, int expected_result, char* testname); |
| 20 /* Return 0 if result is equal to not_expected_result, else return 1. | 19 /* Return 0 if result is equal to not_expected_result, else return 1. |
| 21 * Also update the global gTestSuccess flag if test fails. */ | 20 * Also update the global gTestSuccess flag if test fails. */ |
| 22 int TEST_NEQ(int result, int not_expected_result, char* testname); | 21 int TEST_NEQ(int result, int not_expected_result, char* testname); |
| 23 | 22 |
| 24 /* Test firmware image generation functions. */ | |
| 25 FirmwareImage* GenerateTestFirmwareImage(int algorithm, | |
| 26 const uint8_t* firmware_sign_key, | |
| 27 int firmware_key_version, | |
| 28 int firmware_version, | |
| 29 uint64_t firmware_len, | |
| 30 const char* root_key_file, | |
| 31 const char* firmware_key_file, | |
| 32 uint8_t firmware_data_fill_char); | |
| 33 uint8_t* GenerateTestVerificationBlob(int algorithm, | |
| 34 const uint8_t* firmware_sign_key, | |
| 35 int firmware_key_version, | |
| 36 int firmware_version, | |
| 37 uint64_t firmware_len, | |
| 38 const char* root_key_file, | |
| 39 const char* firmware_key_file); | |
| 40 | |
| 41 /* Test kernel image generation functions. */ | 23 /* Test kernel image generation functions. */ |
| 42 KernelImage* GenerateTestKernelImage(int firmware_sign_algorithm, | 24 KernelImage* GenerateTestKernelImage(int firmware_sign_algorithm, |
| 43 int kernel_sign_algorithm, | 25 int kernel_sign_algorithm, |
| 44 const uint8_t* kernel_sign_key, | 26 const uint8_t* kernel_sign_key, |
| 45 int kernel_key_version, | 27 int kernel_key_version, |
| 46 int kernel_version, | 28 int kernel_version, |
| 47 uint64_t kernel_len, | 29 uint64_t kernel_len, |
| 48 const char* firmware_key_file, | 30 const char* firmware_key_file, |
| 49 const char* kernel_key_file, | 31 const char* kernel_key_file, |
| 50 uint8_t kernel_data_fill_char); | 32 uint8_t kernel_data_fill_char); |
| 51 uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm, | 33 uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm, |
| 52 int kernel_sign_algorithm, | 34 int kernel_sign_algorithm, |
| 53 const uint8_t* kernel_sign_key, | 35 const uint8_t* kernel_sign_key, |
| 54 int kernel_key_version, | 36 int kernel_key_version, |
| 55 int kernel_version, | 37 int kernel_version, |
| 56 uint64_t kernel_len, | 38 uint64_t kernel_len, |
| 57 const char* firmware_key_file, | 39 const char* firmware_key_file, |
| 58 const char* kernel_key_file); | 40 const char* kernel_key_file); |
| 59 | 41 |
| 60 /* Generates a test verification block for rollback tests with a given | |
| 61 * [firmware_key_version] and [firmware_version]. The firmware length is | |
| 62 * assumed to be 1 bytes, and containing { 'F' }. | |
| 63 */ | |
| 64 uint8_t* GenerateRollbackTestVerificationBlob(int firmware_key_version, | |
| 65 int firmware_version); | |
| 66 | |
| 67 /* Generates a test kernel iamge for rollback tests with a given | 42 /* Generates a test kernel iamge for rollback tests with a given |
| 68 * [kernel_key_version} and [kernel_version]. If [is_corrupt] is 1, | 43 * [kernel_key_version} and [kernel_version]. If [is_corrupt] is 1, |
| 69 * then the image has invalid signatures and will fail verification. */ | 44 * then the image has invalid signatures and will fail verification. */ |
| 70 uint8_t* GenerateRollbackTestKernelBlob(int kernel_key_version, | 45 uint8_t* GenerateRollbackTestKernelBlob(int kernel_key_version, |
| 71 int kernel_version, | 46 int kernel_version, |
| 72 int is_corrupt); | 47 int is_corrupt); |
| 73 #endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */ | 48 #endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */ |
| OLD | NEW |