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 // Generate a verified boot image by reading firmware data from in_file_. |
| 29 // Return true on success, false on failure. |
| 30 bool GenerateSignedImage(); |
| 31 |
| 32 // Verify a previously generated signed firmware image using the root key read |
| 33 // from [root_key_pub_file_]. |
| 34 bool VerifySignedImage(); |
| 35 |
| 36 // Output the verified boot image to out_file_. |
| 37 void OutputSignedImage(); |
| 38 |
| 39 |
| 40 bool is_generate() { return is_generate_; } |
| 41 bool is_verify() { return is_verify_; } |
| 42 |
| 43 private: |
| 44 |
| 45 // Check if all options were specified and sane. |
| 46 // Return true on success, false on failure. |
| 47 bool CheckOptions(); |
| 48 |
| 49 FirmwareImage* image_; |
| 50 RSAPublicKey* root_key_pub_; |
| 51 std::string root_key_file_; |
| 52 std::string root_key_pub_file_; |
| 53 int firmware_version_; |
| 54 std::string sign_key_file_; |
| 55 std::string sign_key_pub_file_; |
| 56 int key_version_; |
| 57 int sign_algorithm_; |
| 58 std::string in_file_; |
| 59 std::string out_file_; |
| 60 bool is_generate_; // Are we generating a new image? |
| 61 bool is_verify_; // Are we just verifying an already signed image? |
| 62 }; |
| 63 |
| 64 } // namespace vboot_reference |
| 65 |
| 66 #endif // VBOOT_REFERENCE_FIRMWARE_UTILITY_H_ |
OLD | NEW |