Aktualizr
C++ SOTA Client
fsstorage_read.h
1 #ifndef FSSTORAGE_READ_H_
2 #define FSSTORAGE_READ_H_
3 
4 #include <boost/filesystem.hpp>
5 #include "invstorage.h"
6 
7 class FSStorageRead {
8  public:
9  explicit FSStorageRead(const StorageConfig& config);
10  ~FSStorageRead() = default;
11  bool loadPrimaryKeys(std::string* public_key, std::string* private_key);
12  bool loadPrimaryPublic(std::string* public_key);
13  bool loadPrimaryPrivate(std::string* private_key);
14 
15  bool loadTlsCreds(std::string* ca, std::string* cert, std::string* pkey);
16  bool loadTlsCa(std::string* ca);
17  bool loadTlsCert(std::string* cert);
18  bool loadTlsPkey(std::string* pkey);
19 
20  bool loadRoot(std::string* data, Uptane::RepositoryType repo, Uptane::Version version);
21  bool loadLatestRoot(std::string* data, Uptane::RepositoryType repo) {
22  return loadRoot(data, repo, Uptane::Version());
23  };
24  bool loadNonRoot(std::string* data, Uptane::RepositoryType repo, Uptane::Role role);
25 
26  bool loadDeviceId(std::string* device_id);
27  bool loadEcuSerials(EcuSerials* serials);
28  bool loadMisconfiguredEcus(std::vector<MisconfiguredEcu>* ecus);
29  bool loadEcuRegistered();
30  std::string loadInstalledVersions(std::vector<Uptane::Target>* installed_versions);
31  bool loadInstallationResult(data::OperationResult* result);
32 
33  void cleanUpAll();
34 
35  static bool FSStoragePresent(const StorageConfig& config);
36 
37  private:
38  const StorageConfig& config_;
39 
40  Uptane::Version latest_director_root;
41  Uptane::Version latest_images_root;
42 
43  bool loadTlsCommon(std::string* data, const BasedPath& path_in);
44 
45  bool splitNameRoleVersion(const std::string& full_name, std::string* role_name, int* version);
46  Uptane::Version findMaxVersion(const boost::filesystem::path& meta_directory, Uptane::Role role);
47 
48  void clearPrimaryKeys();
49  void clearTlsCreds();
50  void clearNonRootMeta(Uptane::RepositoryType repo);
51  void clearMetadata();
52  void clearDeviceId();
53  void clearEcuSerials();
54  void clearMisconfiguredEcus();
55  void clearEcuRegistered();
56  void clearInstalledVersions();
57  void clearInstallationResult();
58 };
59 
60 #endif // FSSTORAGE_READ_H_
General data structures.
Definition: types.cc:44
Metadata version numbers.
Definition: tuf.h:58
TUF Roles.
Definition: tuf.h:26
RepositoryType
This must match the repo_type table in sqlstorage.
Definition: tuf.h:19