1 #include "uptane/virtualsecondary.h" 3 #include <boost/algorithm/hex.hpp> 4 #include <boost/filesystem.hpp> 6 #include "crypto/crypto.h" 7 #include "utilities/utils.h" 10 VirtualSecondary::VirtualSecondary(
const SecondaryConfig& sconfig_in) : ManagedSecondary(sconfig_in) {}
12 bool VirtualSecondary::storeFirmware(
const std::string& target_name,
const std::string& content) {
13 Utils::writeFile(sconfig.target_name_path, target_name);
14 Utils::writeFile(sconfig.firmware_path, content);
19 bool VirtualSecondary::getFirmwareInfo(std::string* target_name,
size_t& target_len, std::string* sha256hash) {
22 if (!boost::filesystem::exists(sconfig.target_name_path) || !boost::filesystem::exists(sconfig.firmware_path)) {
23 *target_name = std::string(
"noimage");
26 *target_name = Utils::readFile(sconfig.target_name_path.string());
27 content = Utils::readFile(sconfig.firmware_path.string());
29 *sha256hash = boost::algorithm::to_lower_copy(boost::algorithm::hex(Crypto::sha256digest(content)));
30 target_len = content.size();
Base data types that are used in The Update Framework (TUF), part of UPTANE.