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 // Generate a verified boot image by reading kernel 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 key read |
| 36 // from [firmware_key_pub_file_]. |
| 37 bool VerifySignedImage(); |
| 38 |
| 39 // Output the verified boot kernel image to out_file_. |
| 40 void OutputSignedImage(); |
| 41 |
| 42 bool is_generate() { return is_generate_; } |
| 43 bool is_verify() { return is_verify_; } |
| 44 |
| 45 private: |
| 46 |
| 47 // Check if all options were specified and sane. |
| 48 // Return true on success, false on failure. |
| 49 bool CheckOptions(); |
| 50 |
| 51 KernelImage* image_; |
| 52 RSAPublicKey* firmware_key_pub_; // Root key used for verification. |
| 53 std::string firmware_key_file_; // Private key for signing the kernel key. |
| 54 std::string firmware_key_pub_file_; |
| 55 std::string kernel_key_file_; // Private key for signing the kernel. |
| 56 std::string kernel_key_pub_file_; |
| 57 |
| 58 // Fields of a KernelImage. (read from the command line). |
| 59 int header_version_; |
| 60 int firmware_sign_algorithm_; |
| 61 int kernel_sign_algorithm_; |
| 62 int kernel_key_version_; |
| 63 int kernel_version_; |
| 64 kconfig_options options_; |
| 65 |
| 66 std::string in_file_; |
| 67 std::string out_file_; |
| 68 bool is_generate_; // Are we generating a new image? |
| 69 bool is_verify_; // Are we just verifying an already signed image? |
| 70 }; |
| 71 |
| 72 } // namespace vboot_reference |
| 73 |
| 74 #endif // VBOOT_REFERENCE_FIRMWARE_UTILITY_H_ |
OLD | NEW |