Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
imagesrepository.h
1 #ifndef IMAGES_REPOSITORY_H_
2 #define IMAGES_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  ImagesRepository() : RepositoryCommon(RepositoryType::Image()) {}
16 
17  void resetMeta();
18 
19  bool verifyTargets(const std::string& targets_raw);
20  bool targetsExpired() { return targets->isExpired(TimeStamp::Now()); }
21 
22  bool verifyTimestamp(const std::string& timestamp_raw);
23  bool timestampExpired() { return timestamp.isExpired(TimeStamp::Now()); }
24 
25  bool verifySnapshot(const std::string& snapshot_raw);
26  bool snapshotExpired() { return snapshot.isExpired(TimeStamp::Now()); }
27  int64_t snapshotSize() { return timestamp.snapshot_size(); }
28 
29  Exception getLastException() const { return last_exception; }
30 
31  static std::shared_ptr<Uptane::Targets> verifyDelegation(const std::string& delegation_raw, const Uptane::Role& role,
32  const Targets& parent_target);
33  std::shared_ptr<const Uptane::Targets> getTargets() const { return targets; }
34 
35  bool verifyRoleHashes(const std::string& role_data, const Uptane::Role& role) const;
36  int getRoleVersion(const Uptane::Role& role) const;
37  int64_t getRoleSize(const Uptane::Role& role) const;
38 
39  bool checkMetaOffline(INvStorage& storage);
40  bool updateMeta(INvStorage& storage, const IMetadataFetcher& fetcher) override;
41 
42  private:
43  bool fetchSnapshot(INvStorage& storage, const IMetadataFetcher& fetcher, int local_version);
44  bool fetchTargets(INvStorage& storage, const IMetadataFetcher& fetcher, int local_version);
45 
46  std::shared_ptr<Uptane::Targets> targets;
47  Uptane::TimestampMeta timestamp;
48  Uptane::Snapshot snapshot;
49 
50  Exception last_exception{"", ""};
51 };
52 
53 } // namespace Uptane
54 
55 #endif // IMAGES_REPOSITORY_H
Uptane::RepositoryCommon
Definition: uptanerepository.h:10
Uptane::Snapshot
Definition: tuf.h:504
Uptane::IMetadataFetcher
Definition: fetcher.h:16
Uptane::Targets
Definition: tuf.h:439
Uptane::Exception
Definition: exceptions.h:10
Uptane::Role
TUF Roles.
Definition: tuf.h:57
Uptane
Base data types that are used in The Update Framework (TUF), part of UPTANE.
Definition: secondary_tcp_server.h:8
Uptane::TimestampMeta
Definition: tuf.h:487
Uptane::ImagesRepository
Definition: imagesrepository.h:13
INvStorage
Definition: invstorage.h:126