NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
back-end.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_HPP
23 #define NDN_SECURITY_TPM_BACK_END_HPP
24 
25 #include "../../common.hpp"
26 #include "../../name.hpp"
27 #include "../../encoding/buffer.hpp"
28 #include "../key-params.hpp"
29 
30 namespace ndn {
31 namespace security {
32 namespace tpm {
33 
34 class KeyHandle;
35 
41 class BackEnd : noncopyable
42 {
43 public:
44  class Error : public std::runtime_error
45  {
46  public:
47  explicit
48  Error(const std::string& what)
49  : std::runtime_error(what)
50  {
51  }
52  };
53 
54 public:
55  virtual
56  ~BackEnd();
57 
58 public: // key management
62  bool
63  hasKey(const Name& keyName) const;
64 
71  unique_ptr<KeyHandle>
72  getKeyHandle(const Name& keyName) const;
73 
83  unique_ptr<KeyHandle>
84  createKey(const Name& identity, const KeyParams& params);
85 
93  void
94  deleteKey(const Name& keyName);
95 
102  exportKey(const Name& keyName, const char* pw, size_t pwLen);
103 
114  void
115  importKey(const Name& keyName, const uint8_t* pkcs8, size_t pkcs8Len, const char* pw, size_t pwLen);
116 
122  virtual bool
123  isTerminalMode() const;
124 
132  virtual void
133  setTerminalMode(bool isTerminal) const;
134 
140  virtual bool
141  isTpmLocked() const;
142 
151  virtual bool
152  unlockTpm(const char* pw, size_t pwLen) const;
153 
154 protected: // static helper method
158  static void
159  setKeyName(KeyHandle& keyHandle, const Name& identity, const KeyParams& params);
160 
161 private: // pure virtual methods
165  virtual bool
166  doHasKey(const Name& keyName) const = 0;
167 
171  virtual unique_ptr<KeyHandle>
172  doGetKeyHandle(const Name& keyName) const = 0;
173 
183  virtual unique_ptr<KeyHandle>
184  doCreateKey(const Name& identity, const KeyParams& params) = 0;
185 
191  virtual void
192  doDeleteKey(const Name& keyName) = 0;
193 
198  virtual ConstBufferPtr
199  doExportKey(const Name& keyName, const char* pw, size_t pwLen) = 0;
200 
211  virtual void
212  doImportKey(const Name& keyName, const uint8_t* pkcs8, size_t pkcs8Len, const char* pw, size_t pwLen) = 0;
213 };
214 
215 } // namespace tpm
216 } // namespace security
217 } // namespace ndn
218 
219 #endif // NDN_SECURITY_TPM_BACK_END_HPP
Copyright (c) 2011-2015 Regents of the University of California.
unique_ptr< KeyHandle > createKey(const Name &identity, const KeyParams &params)
Create key for identity according to params.
Definition: back-end.cpp:51
void importKey(const Name &keyName, const uint8_t *pkcs8, size_t pkcs8Len, const char *pw, size_t pwLen)
Import a private key in encrypted PKCS #8 format.
Definition: back-end.cpp:101
virtual void setTerminalMode(bool isTerminal) const
Set the terminal mode of TPM.
Definition: back-end.cpp:148
void deleteKey(const Name &keyName)
Delete a key with name keyName.
Definition: back-end.cpp:86
Abstraction of TPM key handle.
Definition: key-handle.hpp:38
STL namespace.
Abstraction of Tpm back-end.
Definition: back-end.hpp:41
ConstBufferPtr exportKey(const Name &keyName, const char *pw, size_t pwLen)
Definition: back-end.cpp:92
virtual bool unlockTpm(const char *pw, size_t pwLen) const
Unlock TPM.
Definition: back-end.cpp:159
virtual bool isTerminalMode() const
Check if TPM is in terminal mode.
Definition: back-end.cpp:142
Represents an absolute name.
Definition: name.hpp:42
static void setKeyName(KeyHandle &keyHandle, const Name &identity, const KeyParams &params)
Set the key name in keyHandle according to identity and params.
Definition: back-end.cpp:110
bool hasKey(const Name &keyName) const
Definition: back-end.cpp:39
unique_ptr< KeyHandle > getKeyHandle(const Name &keyName) const
Definition: back-end.cpp:45
Base class of key parameters.
Definition: key-params.hpp:35
Error(const std::string &what)
Definition: back-end.hpp:48
virtual bool isTpmLocked() const
Definition: back-end.cpp:153
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:89