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 #ifndef VBOOT_REFERENCE_FIRMWARE_UTILITY_H_ | |
6 #define VBOOT_REFERENCE_FIRMWARE_UTILITY_H_ | |
7 | |
8 #include <string> | |
9 | |
10 class FirmwareImage; | |
11 struct RSAPublicKey; | |
12 | |
13 namespace vboot_reference { | |
14 | |
15 // A class for handling verified boot firmware images. | |
16 class FirmwareUtility { | |
17 public: | |
18 FirmwareUtility(); | |
19 ~FirmwareUtility(); | |
20 | |
21 // Print usage to stderr. | |
22 void PrintUsage(void); | |
23 | |
24 // Parse command line options and populate data members. | |
25 // Return true on success, false on failure. | |
26 bool ParseCmdLineOptions(int argc, char* argv[]); | |
27 | |
28 // Print descriptio of verified boot firmware image. | |
29 void DescribeSignedImage(); | |
30 | |
31 // Generate a verified boot image by reading firmware data from in_file_. | |
32 // Return true on success, false on failure. | |
33 bool GenerateSignedImage(); | |
34 | |
35 // Verify a previously generated signed firmware image using the root key read | |
36 // from [root_key_pub_file_]. | |
37 bool VerifySignedImage(); | |
38 | |
39 // Output the verified boot image to out_file_. | |
40 void OutputSignedImage(); | |
41 | |
42 | |
43 bool is_generate() { return is_generate_; } | |
44 bool is_verify() { return is_verify_; } | |
45 bool is_describe() { return is_describe_; } | |
46 | |
47 private: | |
48 | |
49 // Check if all options were specified and sane. | |
50 // Return true on success, false on failure. | |
51 bool CheckOptions(); | |
52 | |
53 FirmwareImage* image_; | |
54 RSAPublicKey* root_key_pub_; | |
55 std::string root_key_file_; | |
56 std::string root_key_pub_file_; | |
57 std::string firmware_key_file_; | |
58 std::string firmware_key_pub_file_; | |
59 std::string subkey_in_file_; // Existing key signature header. | |
60 std::string in_file_; | |
61 std::string out_file_; | |
62 std::string kernel_subkey_sign_pub_file_; | |
63 int firmware_key_version_; | |
64 int firmware_sign_algorithm_; | |
65 int firmware_version_; | |
66 int kernel_subkey_sign_algorithm_; | |
67 bool is_generate_; // Are we generating a new image? | |
68 bool is_verify_; // Are we just verifying an already signed image? | |
69 bool is_describe_; // Should we print out description of the image? | |
70 bool is_only_vblock_; // Should we just output the verification block? | |
71 bool is_subkey_out_; // Should we just output the subkey header? | |
72 }; | |
73 | |
74 } // namespace vboot_reference | |
75 | |
76 #endif // VBOOT_REFERENCE_FIRMWARE_UTILITY_H_ | |
OLD | NEW |