blob: c8404154693e44efa0fd1eced931ad650d08f000 [file] [log] [blame]
Gaurav Shahce0cc302010-03-24 13:48:55 -07001/* 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
3 * found in the LICENSE file.
4 *
5 */
6
7#ifndef VBOOT_REFERENCE_TEST_COMMON_H_
8#define VBOOT_REFERENCE_TEST_COMMON_H_
9
Gaurav Shah3199eed2010-03-25 13:04:45 -070010#include <stdint.h>
11
12#include "firmware_image.h"
13#include "kernel_image.h"
14
Gaurav Shahce0cc302010-03-24 13:48:55 -070015extern int gTestSuccess;
Gaurav Shahbcd8f4a2010-05-26 13:19:00 -070016
Gaurav Shah3199eed2010-03-25 13:04:45 -070017/* Return 1 if result is equal to expected_result, else return 0.
18 * Also update the global gTestSuccess flag if test fails. */
19int TEST_EQ(int result, int expected_result, char* testname);
Gaurav Shahbcd8f4a2010-05-26 13:19:00 -070020/* Return 0 if result is equal to not_expected_result, else return 1.
21 * Also update the global gTestSuccess flag if test fails. */
22int TEST_NEQ(int result, int not_expected_result, char* testname);
Gaurav Shah3199eed2010-03-25 13:04:45 -070023
24/* Test firmware image generation functions. */
25FirmwareImage* GenerateTestFirmwareImage(int algorithm,
26 const uint8_t* firmware_sign_key,
27 int firmware_key_version,
28 int firmware_version,
Gaurav Shahe450be42010-03-29 21:27:08 -070029 uint64_t firmware_len,
Gaurav Shah3199eed2010-03-25 13:04:45 -070030 const char* root_key_file,
Gaurav Shah463be3f2010-03-29 16:13:45 -070031 const char* firmware_key_file,
32 uint8_t firmware_data_fill_char);
Gaurav Shah02658822010-04-18 16:35:07 -070033uint8_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);
Gaurav Shah3199eed2010-03-25 13:04:45 -070040
41/* Test kernel image generation functions. */
42KernelImage* GenerateTestKernelImage(int firmware_sign_algorithm,
43 int kernel_sign_algorithm,
44 const uint8_t* kernel_sign_key,
45 int kernel_key_version,
46 int kernel_version,
Gaurav Shahe450be42010-03-29 21:27:08 -070047 uint64_t kernel_len,
Gaurav Shah3199eed2010-03-25 13:04:45 -070048 const char* firmware_key_file,
Gaurav Shah463be3f2010-03-29 16:13:45 -070049 const char* kernel_key_file,
50 uint8_t kernel_data_fill_char);
Gaurav Shah3199eed2010-03-25 13:04:45 -070051uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm,
52 int kernel_sign_algorithm,
53 const uint8_t* kernel_sign_key,
54 int kernel_key_version,
55 int kernel_version,
Gaurav Shahe450be42010-03-29 21:27:08 -070056 uint64_t kernel_len,
Gaurav Shah3199eed2010-03-25 13:04:45 -070057 const char* firmware_key_file,
58 const char* kernel_key_file);
Gaurav Shaha82bf262010-03-26 10:38:08 -070059
Gaurav Shah02658822010-04-18 16:35:07 -070060/* 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 */
64uint8_t* GenerateRollbackTestVerificationBlob(int firmware_key_version,
65 int firmware_version);
Gaurav Shahce0cc302010-03-24 13:48:55 -070066
Gaurav Shaha82bf262010-03-26 10:38:08 -070067/* Generates a test kernel iamge for rollback tests with a given
68 * [kernel_key_version} and [kernel_version]. If [is_corrupt] is 1,
69 * then the image has invalid signatures and will fail verification. */
70uint8_t* GenerateRollbackTestKernelBlob(int kernel_key_version,
71 int kernel_version,
72 int is_corrupt);
Gaurav Shahce0cc302010-03-24 13:48:55 -070073#endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */