back-end-file.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_TPM_BACK_END_FILE_HPP
23 #define NDN_SECURITY_TPM_BACK_END_FILE_HPP
24 
25 #include "back-end.hpp"
26 
27 namespace ndn {
28 namespace security {
29 namespace transform {
30 class PrivateKey;
31 } // namespace transform
32 
33 namespace tpm {
34 
41 class BackEndFile : public BackEnd
42 {
43 public:
44  class Error : public BackEnd::Error
45  {
46  public:
47  explicit
48  Error(const std::string& what)
49  : BackEnd::Error(what)
50  {
51  }
52  };
53 
54 public:
59  explicit
60  BackEndFile(const std::string& location = "");
61 
62  ~BackEndFile() override;
63 
64  static const std::string&
65  getScheme();
66 
67 private: // inherited from tpm::BackEnd
71  bool
72  doHasKey(const Name& keyName) const final;
73 
77  unique_ptr<KeyHandle>
78  doGetKeyHandle(const Name& keyName) const final;
79 
91  unique_ptr<KeyHandle>
92  doCreateKey(const Name& identityName, const KeyParams& params) final;
93 
99  void
100  doDeleteKey(const Name& keyName) final;
101 
107  doExportKey(const Name& keyName, const char* pw, size_t pwLen) final;
108 
119  void
120  doImportKey(const Name& keyName, const uint8_t* buf, size_t size, const char* pw, size_t pwLen) final;
121 
122 private:
126  shared_ptr<transform::PrivateKey>
127  loadKey(const Name& keyName) const;
128 
132  void
133  saveKey(const Name& keyName, shared_ptr<transform::PrivateKey> key);
134 
135 private:
136  class Impl;
137  const unique_ptr<Impl> m_impl;
138 };
139 
140 } // namespace tpm
141 } // namespace security
142 } // namespace ndn
143 
144 #endif // NDN_SECURITY_TPM_BACK_END_FILE_HPP
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
The back-end implementation of file-based TPM.
Abstraction of Tpm back-end.
Definition: back-end.hpp:41
Represents an absolute name.
Definition: name.hpp:42
Base class of key parameters.
Definition: key-params.hpp:35
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:89