Aktualizr
C++ SOTA Client
All Classes Namespaces Files Functions Variables Enumerations Enumerator Pages
keymanager.h
1 #ifndef KEYMANAGER_H_
2 #define KEYMANAGER_H_
3 
4 #include "keymanager_config.h"
5 
6 #include "crypto.h"
7 #include "http/httpinterface.h"
8 #include "p11engine.h"
9 #include "utilities/utils.h"
10 
11 class INvStorage;
12 
13 class KeyManager {
14  public:
15  // std::string RSAPSSSign(const std::string &message);
16  // Contains the logic from HttpClient::setCerts()
17  void copyCertsToCurl(HttpInterface &http);
18  KeyManager(std::shared_ptr<INvStorage> backend, KeyManagerConfig config);
19  void loadKeys(const std::string *pkey_content = nullptr, const std::string *cert_content = nullptr,
20  const std::string *ca_content = nullptr);
21  std::string getPkeyFile() const;
22  std::string getCertFile() const;
23  std::string getCaFile() const;
24  std::string getPkey() const;
25  std::string getCert() const;
26  std::string getCa() const;
27  std::string getCN() const;
28  bool isOk() const { return ((getPkey().size() != 0u) && (getCert().size() != 0u) && (getCa().size() != 0u)); }
29  std::string generateUptaneKeyPair();
30  KeyType getUptaneKeyType() const { return config_.uptane_key_type; }
31  Json::Value signTuf(const Json::Value &in_data) const;
32 
33  PublicKey UptanePublicKey() const;
34 
35  private:
36  std::shared_ptr<INvStorage> backend_;
37  const KeyManagerConfig config_;
38  std::unique_ptr<P11EngineGuard> p11_;
39  std::unique_ptr<TemporaryFile> tmp_pkey_file;
40  std::unique_ptr<TemporaryFile> tmp_cert_file;
41  std::unique_ptr<TemporaryFile> tmp_ca_file;
42 };
43 
44 #endif // KEYMANAGER_H_
KeyManager
Definition: keymanager.h:13
HttpInterface
Definition: httpinterface.h:38
PublicKey
Definition: crypto.h:26
KeyManagerConfig
Definition: keymanager_config.h:9
INvStorage
Definition: invstorage.h:109