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_KERNEL_UTILITY_H_ | |
6 #define VBOOT_REFERENCE_KERNEL_UTILITY_H_ | |
7 | |
8 #include <string> | |
9 | |
10 extern "C" { | |
11 #include "kernel_image.h" | |
12 } | |
13 | |
14 struct RSAPublicKey; | |
15 | |
16 namespace vboot_reference { | |
17 | |
18 // A class for handling verified boot kernel images. | |
19 class KernelUtility { | |
20 public: | |
21 KernelUtility(); | |
22 ~KernelUtility(); | |
23 | |
24 // Print usage to stderr. | |
25 void PrintUsage(void); | |
26 | |
27 // Parse command line options and populate data members. | |
28 // Return true on success, false on failure. | |
29 bool ParseCmdLineOptions(int argc, char* argv[]); | |
30 | |
31 // Print description of a verified boot kernel image. | |
32 void DescribeSignedImage(); | |
33 | |
34 // Generate a verified boot image by reading kernel data from in_file_. | |
35 // Return true on success, false on failure. | |
36 bool GenerateSignedImage(); | |
37 | |
38 // Verify a previously generated signed firmware image using the key read | |
39 // from [firmware_key_pub_file_]. | |
40 bool VerifySignedImage(); | |
41 | |
42 // Output the verified boot kernel image to out_file_. | |
43 void OutputSignedImage(); | |
44 | |
45 bool is_generate() { return is_generate_; } | |
46 bool is_verify() { return is_verify_; } | |
47 bool is_describe() { return is_describe_; } | |
48 | |
49 private: | |
50 | |
51 // Check if all options were specified and sane. | |
52 // Return true on success, false on failure. | |
53 bool CheckOptions(); | |
54 | |
55 KernelImage* image_; | |
56 RSAPublicKey* firmware_key_pub_; // Root key used for verification. | |
57 std::string firmware_key_file_; // Private key for signing the kernel key. | |
58 std::string firmware_key_pub_file_; | |
59 std::string kernel_key_file_; // Private key for signing the kernel. | |
60 std::string kernel_key_pub_file_; | |
61 std::string subkey_in_file_; // Existing key signature header. | |
62 std::string config_file_; // File containing kernel commandline parameters | |
63 std::string bootloader_file_; // Embedded bootloader code | |
64 std::string vmlinuz_file_; // Input vmlinuz to be embedded in signed blob. | |
65 | |
66 // Fields of a KernelImage. (read from the command line). | |
67 int header_version_; | |
68 int firmware_sign_algorithm_; | |
69 int kernel_sign_algorithm_; | |
70 int kernel_key_version_; | |
71 int kernel_version_; | |
72 int padding_; | |
73 uint64_t kernel_len_; | |
74 uint8_t* kernel_config_; | |
75 | |
76 std::string in_file_; | |
77 std::string out_file_; | |
78 bool is_generate_; // Are we generating a new image? | |
79 bool is_verify_; // Are we just verifying an already signed image? | |
80 bool is_describe_; // Should we print out description of the image? | |
81 bool is_only_vblock_; // Should we just output the verification block? | |
82 bool is_subkey_out_; // Should we just output the subkey header? | |
83 }; | |
84 | |
85 } // namespace vboot_reference | |
86 | |
87 #endif // VBOOT_REFERENCE_FIRMWARE_UTILITY_H_ | |
OLD | NEW |