1 #include "uptane/uptanerepository.h" 5 #include <openssl/bio.h> 6 #include <openssl/pem.h> 7 #include <openssl/x509.h> 8 #include <boost/algorithm/hex.hpp> 9 #include <boost/algorithm/string/replace.hpp> 10 #include <boost/algorithm/string/trim.hpp> 13 #include "bootstrap/bootstrap.h" 14 #include "crypto/crypto.h" 15 #include "crypto/openssl_compat.h" 16 #include "logging/logging.h" 17 #include "storage/invstorage.h" 18 #include "utilities/utils.h" 22 bool RepositoryCommon::initRoot(
const std::string& root_raw) {
24 root = Root(type, Utils::parseJSON(root_raw));
25 root = Root(type, Utils::parseJSON(root_raw), root);
26 }
catch (
const std::exception& e) {
27 LOG_ERROR <<
"Loading initial root failed: " << e.what();
34 bool RepositoryCommon::verifyRoot(
const std::string& root_raw) {
36 int prev_version = root.version();
37 root = Root(type, Utils::parseJSON(root_raw), root);
38 if (root.version() != prev_version + 1) {
39 LOG_ERROR <<
"Version in root metadata doesn't match the expected value";
42 }
catch (
const std::exception& e) {
43 LOG_ERROR <<
"Signature verification for root metadata failed: " << e.what();
49 void RepositoryCommon::resetRoot() { root = Root(Root::Policy::kAcceptAll); }
51 Json::Value Manifest::signManifest(
const Json::Value& version_manifests) {
53 manifest[
"primary_ecu_serial"] = primary_ecu_serial.ToString();
54 manifest[
"ecu_version_manifests"] = version_manifests;
56 return keys_.signTuf(manifest);
59 Json::Value Manifest::signVersionManifest(
const Json::Value& primary_version_manifests) {
60 Json::Value ecu_version_signed = keys_.signTuf(primary_version_manifests);
61 return ecu_version_signed;
Base data types that are used in The Update Framework (TUF), part of UPTANE.