Aktualizr
C++ SOTA Client
uptanerepository.h
1 #ifndef UPTANE_REPOSITORY_H_
2 #define UPTANE_REPOSITORY_H_
3 
4 #include <vector>
5 
6 #include "json/json.h"
7 
8 #include "config/config.h"
9 #include "crypto/crypto.h"
10 #include "crypto/keymanager.h"
11 #include "logging/logging.h"
12 #include "storage/invstorage.h"
13 
14 namespace Uptane {
15 
16 class Manifest {
17  public:
18  Manifest(const Config &config_in, std::shared_ptr<INvStorage> storage_in)
19  : storage_{std::move(storage_in)}, keys_(storage_, config_in.keymanagerConfig()) {}
20 
21  Json::Value signManifest(const Json::Value &version_manifests);
22  Json::Value signVersionManifest(const Json::Value &primary_version_manifests);
23 
24  void setPrimaryEcuSerialHwId(const std::pair<Uptane::EcuSerial, Uptane::HardwareIdentifier> &serials) {
25  primary_ecu_serial = serials.first;
26  primary_hardware_id = serials.second;
27  }
28 
29  EcuSerial getPrimaryEcuSerial() { return primary_ecu_serial; }
30 
31  private:
32  Uptane::EcuSerial primary_ecu_serial{Uptane::EcuSerial::Unknown()};
33  Uptane::HardwareIdentifier primary_hardware_id{Uptane::HardwareIdentifier::Unknown()};
34  std::shared_ptr<INvStorage> storage_;
35  KeyManager keys_;
36 };
37 
39  public:
40  RepositoryCommon(RepositoryType type_in) : type{type_in} {}
41  bool initRoot(const std::string &root_raw);
42  bool verifyRoot(const std::string &root_raw);
43  int rootVersion() { return root.version(); }
44  bool rootExpired() { return root.isExpired(TimeStamp::Now()); }
45 
46  protected:
47  void resetRoot();
48  Root root;
49  RepositoryType type;
50 };
51 } // namespace Uptane
52 
53 #endif
Configuration object for an aktualizr instance running on a primary ECU.
Definition: config.h:100
RepositoryType
This must match the repo_type table in sqlstorage.
Definition: tuf.h:18
Base data types that are used in The Update Framework (TUF), part of UPTANE.