OLD | NEW |
| (Empty) |
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 | |
3 * found in the LICENSE file. | |
4 * | |
5 * API definitions for a verified boot firmware image. | |
6 * (Userland Portion) | |
7 */ | |
8 | |
9 #ifndef VBOOT_REFERENCE_FIRMWARE_IMAGE_H_ | |
10 #define VBOOT_REFERENCE_FIRMWARE_IMAGE_H_ | |
11 | |
12 #include "firmware_image_fw.h" | |
13 | |
14 /* Allocate and return a new FirmwareImage structure. */ | |
15 FirmwareImage* FirmwareImageNew(void); | |
16 | |
17 /* Deep free the contents of [fw]. */ | |
18 void FirmwareImageFree(FirmwareImage* fw); | |
19 | |
20 /* Read firmware data from file named [input_file]. | |
21 * | |
22 * Returns a filled up FirmwareImage structure on success, NULL on error. | |
23 */ | |
24 FirmwareImage* ReadFirmwareImage(const char* input_file); | |
25 | |
26 /* Get the length of the header for image [image]. */ | |
27 int GetFirmwareHeaderLen(const FirmwareImage* image); | |
28 | |
29 /* Calculate and store the firmware header checksum of [image] | |
30 * in [header_checksum]. | |
31 * | |
32 * [header_checksum] must be a valid pointer to a buffer of | |
33 * SHA512_DIGEST_SIZE. | |
34 */ | |
35 void CalculateFirmwareHeaderChecksum(const FirmwareImage *image, | |
36 uint8_t* header_checksum); | |
37 | |
38 /* Get firmware header binary blob from an [image]. | |
39 * | |
40 * Caller owns the returned pointer and must Free() it. | |
41 */ | |
42 uint8_t* GetFirmwareHeaderBlob(const FirmwareImage* image); | |
43 | |
44 /* Get firmware preamble binary blob from an [image]. | |
45 * | |
46 * Caller owns the returned pointer and must Free() it. | |
47 */ | |
48 uint8_t* GetFirmwarePreambleBlob(const FirmwareImage* image); | |
49 | |
50 /* Get a verified firmware binary blob from an [image] and fill its | |
51 * length into blob_len. | |
52 * | |
53 * Caller owns the returned pointer and must Free() it. | |
54 */ | |
55 uint8_t* GetFirmwareBlob(const FirmwareImage* image, uint64_t* blob_len); | |
56 | |
57 /* Write firmware data from [image] into a file named [input_file]. | |
58 * | |
59 * If [is_just_vblock] is non-zero, only the verification block (excluding the | |
60 * actual firmware_data) is output. | |
61 * if [is_subkey_out] is non-zero, only the firmware key verification (subkey) | |
62 * header is output. | |
63 * | |
64 * Return 1 on success, 0 on failure. | |
65 */ | |
66 int WriteFirmwareImage(const char* input_file, | |
67 const FirmwareImage* image, | |
68 int is_only_vblock, | |
69 int is_subkey_out); | |
70 | |
71 /* Pretty print the contents of [image]. Only headers and metadata information | |
72 * is printed. | |
73 */ | |
74 void PrintFirmwareImage(const FirmwareImage* image); | |
75 | |
76 /* Performs a chained verify of the firmware [image]. | |
77 * | |
78 * Returns 0 on success, error code on failure. | |
79 */ | |
80 int VerifyFirmwareImage(const RSAPublicKey* root_key, | |
81 const FirmwareImage* image); | |
82 | |
83 /* Maps error codes from VerifyFirmware() to error description. */ | |
84 const char* VerifyFirmwareErrorString(int error); | |
85 | |
86 /* Add a root key signature to the key header to a firmware image [image] | |
87 * using the private root key in file [root_key_file]. | |
88 * | |
89 * Return 1 on success, 0 on failure. | |
90 */ | |
91 int AddFirmwareKeySignature(FirmwareImage* image, const char* root_key_file); | |
92 | |
93 /* Add firmware and preamble signature to a firmware image [image] | |
94 * using the private signing key in file [signing_key_file]. | |
95 * | |
96 * Return 1 on success, 0 on failure. | |
97 */ | |
98 int AddFirmwareSignature(FirmwareImage* image, const char* signing_key_file); | |
99 | |
100 #endif /* VBOOT_REFERENCE_FIRMWARE_IMAGE_H_ */ | |
OLD | NEW |