1 #ifndef UPTANE_SECONDARYCONFIG_H_ 2 #define UPTANE_SECONDARYCONFIG_H_ 6 #include <sys/socket.h> 7 #include <boost/filesystem.hpp> 8 #include "utilities/exceptions.h" 10 #include "utilities/utils.h" 14 enum class SecondaryType {
32 if (!boost::filesystem::exists(config_file)) {
35 Json::Value config_json = Utils::parseJSONFile(config_file);
37 std::string stype = config_json[
"secondary_type"].asString();
38 if (stype ==
"virtual") {
39 secondary_type = Uptane::SecondaryType::kVirtual;
40 }
else if (stype ==
"legacy") {
41 throw FatalException(
"Legacy secondaries should be initialized with --legacy-interface.");
42 }
else if (stype ==
"ip_uptane") {
43 secondary_type = Uptane::SecondaryType::kIpUptane;
44 }
else if (stype ==
"opcua_uptane") {
45 secondary_type = Uptane::SecondaryType::kOpcuaUptane;
47 throw FatalException(std::string(
"Unrecognized secondary type: ") + stype);
49 ecu_serial = config_json[
"ecu_serial"].asString();
50 ecu_hardware_id = config_json[
"ecu_hardware_id"].asString();
51 partial_verifying = config_json[
"partial_verifying"].asBool();
52 ecu_private_key = config_json[
"ecu_private_key"].asString();
53 ecu_public_key = config_json[
"ecu_public_key"].asString();
55 full_client_dir = boost::filesystem::path(config_json[
"full_client_dir"].asString());
56 firmware_path = boost::filesystem::path(config_json[
"firmware_path"].asString());
57 metadata_path = boost::filesystem::path(config_json[
"metadata_path"].asString());
58 target_name_path = boost::filesystem::path(config_json[
"target_name_path"].asString());
61 std::string key_type_str = config_json[
"key_type"].asString();
62 if (key_type_str.size() != 0u) {
63 if (key_type_str ==
"RSA2048") {
64 key_type = KeyType::kRSA2048;
65 }
else if (key_type_str ==
"RSA3072") {
66 key_type = KeyType::kRSA3072;
67 }
else if (key_type_str ==
"RSA4096") {
68 key_type = KeyType::kRSA4096;
69 }
else if (key_type_str ==
"ED25519") {
70 key_type = KeyType::kED25519;
74 SecondaryType secondary_type{};
75 std::string ecu_serial;
76 std::string ecu_hardware_id;
77 bool partial_verifying{};
78 std::string ecu_private_key;
79 std::string ecu_public_key;
80 KeyType key_type{KeyType::kRSA2048};
82 std::string opcua_lds_url;
84 boost::filesystem::path full_client_dir;
85 boost::filesystem::path firmware_path;
86 boost::filesystem::path metadata_path;
87 boost::filesystem::path target_name_path;
89 boost::filesystem::path flasher;
91 sockaddr_storage ip_addr{};
Base data types that are used in The Update Framework (TUF), part of UPTANE.