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 | 5 |
6 #ifndef VBOOT_REFERENCE_GBB_UTILITY_H_ | 6 #ifndef VBOOT_REFERENCE_GBB_UTILITY_H_ |
7 #define VBOOT_REFERENCE_GBB_UTILITY_H_ | 7 #define VBOOT_REFERENCE_GBB_UTILITY_H_ |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include "gbb_header.h" | 10 #include "gbb_header.h" |
11 | 11 |
12 namespace vboot_reference { | 12 namespace vboot_reference { |
13 | 13 |
14 class GoogleBinaryBlockUtil { | 14 class GoogleBinaryBlockUtil { |
15 public: | 15 public: |
16 // enumerate of available data fields | 16 // enumerate of available data fields |
17 enum PROPINDEX { | 17 enum PROPINDEX { |
18 PROP_HWID, // hardware id | 18 PROP_HWID, // hardware id |
19 PROP_ROOTKEY, // root key | 19 PROP_ROOTKEY, // root key |
20 PROP_BMPFV, // bitmap FV | 20 PROP_BMPFV, // bitmap FV |
| 21 PROP_RCVKEY, // recovery key |
21 PROP_RANGE, // indicator of valid property range | 22 PROP_RANGE, // indicator of valid property range |
22 }; | 23 }; |
23 | 24 |
24 GoogleBinaryBlockUtil(); | 25 GoogleBinaryBlockUtil(); |
25 ~GoogleBinaryBlockUtil(); | 26 ~GoogleBinaryBlockUtil(); |
26 | 27 |
27 // load GBB from a BIOS image file. | 28 // load GBB from a BIOS image file. |
28 // return true if a valid GBB was retrieved. | 29 // return true if a valid GBB was retrieved. |
29 bool load_from_file(const char *filename); | 30 bool load_from_file(const char *filename); |
30 | 31 |
(...skipping 10 matching lines...) Expand all Loading... |
41 bool set_property(PROPINDEX i, const std::string &value); | 42 bool set_property(PROPINDEX i, const std::string &value); |
42 | 43 |
43 // get a readable name by a property index. | 44 // get a readable name by a property index. |
44 // return the name for valid properties, otherwise unexpected empty string. | 45 // return the name for valid properties, otherwise unexpected empty string. |
45 std::string get_property_name(PROPINDEX i) const; | 46 std::string get_property_name(PROPINDEX i) const; |
46 | 47 |
47 // quick getters and setters of known properties in GBB | 48 // quick getters and setters of known properties in GBB |
48 bool set_hwid(const char *hwid); // NOTE: hwid is NUL-terminated. | 49 bool set_hwid(const char *hwid); // NOTE: hwid is NUL-terminated. |
49 bool set_rootkey(const std::string &value); | 50 bool set_rootkey(const std::string &value); |
50 bool set_bmpfv(const std::string &value); | 51 bool set_bmpfv(const std::string &value); |
| 52 bool set_recovery_key(const std::string &value); |
51 std::string get_hwid() const { return get_property(PROP_HWID); } | 53 std::string get_hwid() const { return get_property(PROP_HWID); } |
52 std::string get_rootkey() const { return get_property(PROP_ROOTKEY); } | 54 std::string get_rootkey() const { return get_property(PROP_ROOTKEY); } |
53 std::string get_bmpfv() const { return get_property(PROP_BMPFV); } | 55 std::string get_bmpfv() const { return get_property(PROP_BMPFV); } |
| 56 std::string get_recovery_key() const { return get_property(PROP_RCVKEY); } |
54 | 57 |
55 private: | 58 private: |
56 // clear all cached data and initialize to original state | 59 // clear all cached data and initialize to original state |
57 void initialize(); | 60 void initialize(); |
58 | 61 |
59 // search and count for GBB signatures in loaded image. | 62 // search and count for GBB signatures in loaded image. |
60 // return the number of signatures found. | 63 // return the number of signatures found. |
61 int search_header_signatures(const std::string &image, long *poffset) const; | 64 int search_header_signatures(const std::string &image, long *poffset) const; |
62 | 65 |
63 // load and check header structure from image by given offset. | 66 // load and check header structure from image by given offset. |
(...skipping 13 matching lines...) Expand all Loading... |
77 long header_offset_; // offset to GBB header in file_content_ | 80 long header_offset_; // offset to GBB header in file_content_ |
78 bool is_valid_gbb; // if we are holding a valid GBB | 81 bool is_valid_gbb; // if we are holding a valid GBB |
79 | 82 |
80 bool verbose; // provide verbose messages | 83 bool verbose; // provide verbose messages |
81 }; | 84 }; |
82 | 85 |
83 } // namespace vboot_reference | 86 } // namespace vboot_reference |
84 | 87 |
85 #endif // VBOOT_REFERENCE_GBB_UTILITY_H_ | 88 #endif // VBOOT_REFERENCE_GBB_UTILITY_H_ |
86 | 89 |
OLD | NEW |