blob: d73dc0eaff4fb5148f82d896bec26ade794fc893 [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 Shah3199eed2010-03-25 13:04:45 -070016/* Return 1 if result is equal to expected_result, else return 0.
17 * Also update the global gTestSuccess flag if test fails. */
18int TEST_EQ(int result, int expected_result, char* testname);
19
20/* Test firmware image generation functions. */
21FirmwareImage* GenerateTestFirmwareImage(int algorithm,
22 const uint8_t* firmware_sign_key,
23 int firmware_key_version,
24 int firmware_version,
Gaurav Shahe450be42010-03-29 21:27:08 -070025 uint64_t firmware_len,
Gaurav Shah3199eed2010-03-25 13:04:45 -070026 const char* root_key_file,
Gaurav Shah463be3f2010-03-29 16:13:45 -070027 const char* firmware_key_file,
28 uint8_t firmware_data_fill_char);
Gaurav Shah02658822010-04-18 16:35:07 -070029uint8_t* GenerateTestVerificationBlob(int algorithm,
30 const uint8_t* firmware_sign_key,
31 int firmware_key_version,
32 int firmware_version,
33 uint64_t firmware_len,
34 const char* root_key_file,
35 const char* firmware_key_file);
Gaurav Shah3199eed2010-03-25 13:04:45 -070036
37/* Test kernel image generation functions. */
38KernelImage* GenerateTestKernelImage(int firmware_sign_algorithm,
39 int kernel_sign_algorithm,
40 const uint8_t* kernel_sign_key,
41 int kernel_key_version,
42 int kernel_version,
Gaurav Shahe450be42010-03-29 21:27:08 -070043 uint64_t kernel_len,
Gaurav Shah3199eed2010-03-25 13:04:45 -070044 const char* firmware_key_file,
Gaurav Shah463be3f2010-03-29 16:13:45 -070045 const char* kernel_key_file,
46 uint8_t kernel_data_fill_char);
Gaurav Shah3199eed2010-03-25 13:04:45 -070047uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm,
48 int kernel_sign_algorithm,
49 const uint8_t* kernel_sign_key,
50 int kernel_key_version,
51 int kernel_version,
Gaurav Shahe450be42010-03-29 21:27:08 -070052 uint64_t kernel_len,
Gaurav Shah3199eed2010-03-25 13:04:45 -070053 const char* firmware_key_file,
54 const char* kernel_key_file);
Gaurav Shaha82bf262010-03-26 10:38:08 -070055
Gaurav Shah02658822010-04-18 16:35:07 -070056/* Generates a test verification block for rollback tests with a given
57 * [firmware_key_version] and [firmware_version]. The firmware length is
58 * assumed to be 1 bytes, and containing { 'F' }.
59 */
60uint8_t* GenerateRollbackTestVerificationBlob(int firmware_key_version,
61 int firmware_version);
Gaurav Shahce0cc302010-03-24 13:48:55 -070062
Gaurav Shaha82bf262010-03-26 10:38:08 -070063/* Generates a test kernel iamge for rollback tests with a given
64 * [kernel_key_version} and [kernel_version]. If [is_corrupt] is 1,
65 * then the image has invalid signatures and will fail verification. */
66uint8_t* GenerateRollbackTestKernelBlob(int kernel_key_version,
67 int kernel_version,
68 int is_corrupt);
Gaurav Shahce0cc302010-03-24 13:48:55 -070069#endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */