1 #include "uptane/legacysecondary.h" 5 #include <boost/algorithm/hex.hpp> 6 #include <boost/filesystem.hpp> 8 #include "crypto/crypto.h" 9 #include "logging/logging.h" 10 #include "utilities/utils.h" 13 LegacySecondary::LegacySecondary(
const SecondaryConfig& sconfig_in) : ManagedSecondary(sconfig_in) {}
15 bool LegacySecondary::storeFirmware(
const std::string& target_name,
const std::string& content) {
17 Utils::writeFile(sconfig.target_name_path, target_name);
18 Utils::writeFile(sconfig.firmware_path, content);
21 std::stringstream command;
23 command << sconfig.flasher.string() <<
" install-software --hardware-identifier " << sconfig.ecu_hardware_id
24 <<
" --ecu-identifier " << getSerial() <<
" --firmware " << sconfig.firmware_path.string() <<
" --loglevel " 25 << loggerGetSeverity();
26 int rs = Utils::shell(command.str(), &output);
33 LOG_ERROR <<
"Legacy external flasher install-software command failed: " << output;
38 bool LegacySecondary::getFirmwareInfo(std::string* target_name,
size_t& target_len, std::string* sha256hash) {
42 if (!boost::filesystem::exists(sconfig.target_name_path) || !boost::filesystem::exists(sconfig.firmware_path)) {
43 *target_name = std::string(
"noimage");
46 *target_name = Utils::readFile(sconfig.target_name_path.string());
47 content = Utils::readFile(sconfig.firmware_path.string());
49 *sha256hash = boost::algorithm::to_lower_copy(boost::algorithm::hex(Crypto::sha256digest(content)));
50 target_len = content.size();
Base data types that are used in The Update Framework (TUF), part of UPTANE.