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