Aktualizr
C++ SOTA Client
imagerepository.h
1 #ifndef IMAGE_REPOSITORY_H_
2 #define IMAGE_REPOSITORY_H_
3 
4 #include <map>
5 #include <vector>
6 
7 #include "uptanerepository.h"
8 
9 namespace Uptane {
10 
11 constexpr int kDelegationsMaxDepth = 5;
12 
14  public:
15  ImageRepository() : RepositoryCommon(RepositoryType::Image()) {}
16 
17  void resetMeta();
18 
19  void verifyTargets(const std::string& targets_raw, bool prefetch);
20 
21  void verifyTimestamp(const std::string& timestamp_raw);
22 
23  void verifySnapshot(const std::string& snapshot_raw, bool prefetch);
24 
25  static std::shared_ptr<Uptane::Targets> verifyDelegation(const std::string& delegation_raw, const Uptane::Role& role,
26  const Targets& parent_target);
27  std::shared_ptr<const Uptane::Targets> getTargets() const { return targets; }
28 
29  void verifyRoleHashes(const std::string& role_data, const Uptane::Role& role, bool prefetch) const;
30  int getRoleVersion(const Uptane::Role& role) const;
31  int64_t getRoleSize(const Uptane::Role& role) const;
32 
33  void checkMetaOffline(INvStorage& storage);
34  void updateMeta(INvStorage& storage, const IMetadataFetcher& fetcher) override;
35 
36  private:
37  void checkTimestampExpired();
38  void checkSnapshotExpired();
39  int64_t snapshotSize() const { return timestamp.snapshot_size(); }
40  void fetchSnapshot(INvStorage& storage, const IMetadataFetcher& fetcher, int local_version);
41  void fetchTargets(INvStorage& storage, const IMetadataFetcher& fetcher, int local_version);
42  void checkTargetsExpired();
43 
44  std::shared_ptr<Uptane::Targets> targets;
45  Uptane::TimestampMeta timestamp;
46  Uptane::Snapshot snapshot;
47 };
48 
49 } // namespace Uptane
50 
51 #endif // IMAGE_REPOSITORY_H_
Uptane::RepositoryCommon
Definition: uptanerepository.h:10
Uptane::ImageRepository
Definition: imagerepository.h:13
Uptane::Snapshot
Definition: tuf.h:336
Uptane::IMetadataFetcher
Definition: fetcher.h:16
Uptane::Targets
Definition: tuf.h:271
Uptane::Role
TUF Roles.
Definition: tuf.h:61
Uptane
Base data types that are used in The Update Framework (TUF), part of Uptane.
Definition: packagemanagerinterface.h:18
Uptane::TimestampMeta
Definition: tuf.h:319
INvStorage
Definition: invstorage.h:43