blob: a449bddd8a952a4a788a7872e5f3f1a9e03938c0 [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,
25 int firmware_len,
26 const char* root_key_file,
27 const char* firmware_key_file);
28uint8_t* GenerateTestFirmwareBlob(int algorithm,
29 const uint8_t* firmware_sign_key,
30 int firmware_key_version,
31 int firmware_version,
32 int firmware_len,
33 const char* root_key_file,
34 const char* firmware_key_file);
35
36/* Test kernel image generation functions. */
37KernelImage* GenerateTestKernelImage(int firmware_sign_algorithm,
38 int kernel_sign_algorithm,
39 const uint8_t* kernel_sign_key,
40 int kernel_key_version,
41 int kernel_version,
42 int kernel_len,
43 const char* firmware_key_file,
44 const char* kernel_key_file);
45uint8_t* GenerateTestKernelBlob(int firmware_sign_algorithm,
46 int kernel_sign_algorithm,
47 const uint8_t* kernel_sign_key,
48 int kernel_key_version,
49 int kernel_version,
50 int kernel_len,
51 const char* firmware_key_file,
52 const char* kernel_key_file);
53/* Generates a test firmware image for rollback tests with a given
54 * [firmware_key_version] and [firmware_version]. If [is_corrupt] is 1,
55 * then the image has invalid signatures and will fail verification. */
56uint8_t* GenerateRollbackTestImage(int firmware_key_version,
57 int firmware_version,
58 int is_corrupt);
Gaurav Shahce0cc302010-03-24 13:48:55 -070059
60#endif /* VBOOT_REFERENCE_TEST_COMMON_H_ */