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) const;
12  bool loadPrimaryPublic(std::string* public_key) const;
13  bool loadPrimaryPrivate(std::string* private_key) const;
14 
15  bool loadTlsCreds(std::string* ca, std::string* cert, std::string* pkey) const;
16  bool loadTlsCa(std::string* ca) const;
17  bool loadTlsCert(std::string* cert) const;
18  bool loadTlsPkey(std::string* pkey) const;
19 
20  bool loadRoot(std::string* data, Uptane::RepositoryType repo, Uptane::Version version) const;
21  bool loadLatestRoot(std::string* data, Uptane::RepositoryType repo) const {
22  return loadRoot(data, repo, Uptane::Version());
23  };
24  bool loadNonRoot(std::string* data, Uptane::RepositoryType repo, const Uptane::Role& role) const;
25 
26  bool loadDeviceId(std::string* device_id) const;
27  bool loadEcuSerials(EcuSerials* serials) const;
28  bool loadMisconfiguredEcus(std::vector<MisconfiguredEcu>* ecus) const;
29  bool loadEcuRegistered() const;
30  bool loadInstalledVersions(std::vector<Uptane::Target>* installed_versions, size_t* current_version) const;
31 
32  void cleanUpAll();
33 
34  static bool FSStoragePresent(const StorageConfig& config);
35 
36  private:
37  const StorageConfig& config_;
38 
39  Uptane::Version latest_director_root;
40  Uptane::Version latest_image_root;
41 
42  bool loadTlsCommon(std::string* data, const utils::BasedPath& path_in) const;
43 
44  static bool splitNameRoleVersion(const std::string& full_name, std::string* role_name, int* version);
45  static Uptane::Version findMaxVersion(const boost::filesystem::path& meta_directory, const Uptane::Role& role);
46 
47  void clearPrimaryKeys();
48  void clearTlsCreds();
49  void clearNonRootMeta(Uptane::RepositoryType repo);
50  void clearMetadata();
51  void clearDeviceId();
52  void clearEcuSerials();
53  void clearMisconfiguredEcus();
54  void clearEcuRegistered();
55  void clearInstalledVersions();
56  void clearInstallationResult();
57 };
58 
59 #endif // FSSTORAGE_READ_H_
Uptane::Version
Metadata version numbers.
Definition: tuf.h:120
StorageConfig
Definition: config.h:111
data
General data structures.
Definition: types.h:217
utils::BasedPath
The BasedPath class Can represent an absolute or relative path, only readable through the BasePath::g...
Definition: types.h:31
Uptane::RepositoryType
Definition: tuf.h:21
Uptane::Role
TUF Roles.
Definition: tuf.h:61
FSStorageRead
Definition: fsstorage_read.h:7