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; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SECURITY_TPM_BACK_END_HPP
23 #define NDN_SECURITY_TPM_BACK_END_HPP
24 
27 #include "ndn-cxx/name.hpp"
28 
29 namespace ndn {
30 namespace security {
31 namespace tpm {
32 
33 class KeyHandle;
34 
40 class BackEnd : noncopyable
41 {
42 public:
43  class Error : public std::runtime_error
44  {
45  public:
46  using std::runtime_error::runtime_error;
47  };
48 
49 public:
50  virtual
51  ~BackEnd();
52 
53 public: // key management
59  bool
60  hasKey(const Name& keyName) const;
61 
70  unique_ptr<KeyHandle>
71  getKeyHandle(const Name& keyName) const;
72 
80  unique_ptr<KeyHandle>
81  createKey(const Name& identityName, const KeyParams& params);
82 
91  void
92  deleteKey(const Name& keyName);
93 
105  exportKey(const Name& keyName, const char* pw, size_t pwLen);
106 
118  void
119  importKey(const Name& keyName, const uint8_t* pkcs8, size_t pkcs8Len, const char* pw, size_t pwLen);
120 
128  virtual bool
129  isTerminalMode() const;
130 
137  virtual void
138  setTerminalMode(bool isTerminal) const;
139 
147  virtual bool
148  isTpmLocked() const;
149 
160  virtual bool
161  unlockTpm(const char* pw, size_t pwLen) const;
162 
163 protected: // static helper methods
167  static void
168  setKeyName(KeyHandle& keyHandle, const Name& identity, const KeyParams& params);
169 
170 private: // pure virtual methods
171  virtual bool
172  doHasKey(const Name& keyName) const = 0;
173 
174  virtual unique_ptr<KeyHandle>
175  doGetKeyHandle(const Name& keyName) const = 0;
176 
177  virtual unique_ptr<KeyHandle>
178  doCreateKey(const Name& identity, const KeyParams& params) = 0;
179 
180  virtual void
181  doDeleteKey(const Name& keyName) = 0;
182 
183  virtual ConstBufferPtr
184  doExportKey(const Name& keyName, const char* pw, size_t pwLen) = 0;
185 
186  virtual void
187  doImportKey(const Name& keyName, const uint8_t* pkcs8, size_t pkcs8Len, const char* pw, size_t pwLen) = 0;
188 };
189 
190 } // namespace tpm
191 } // namespace security
192 } // namespace ndn
193 
194 #endif // NDN_SECURITY_TPM_BACK_END_HPP
Copyright (c) 2011-2015 Regents of the University of California.
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
unique_ptr< KeyHandle > createKey(const Name &identityName, const KeyParams &params)
Create a key for identityName according to params.
Definition: back-end.cpp:51
virtual void setTerminalMode(bool isTerminal) const
Set the terminal mode of the TPM.
Definition: back-end.cpp:148
void deleteKey(const Name &keyName)
Delete the key with name keyName.
Definition: back-end.cpp:86
Abstraction of TPM key handle.
Definition: key-handle.hpp:37
Abstract interface for a TPM backend implementation.
Definition: back-end.hpp:40
ConstBufferPtr exportKey(const Name &keyName, const char *pw, size_t pwLen)
Get the private key with name keyName in encrypted PKCS #8 format.
Definition: back-end.cpp:92
virtual bool unlockTpm(const char *pw, size_t pwLen) const
Unlock the TPM.
Definition: back-end.cpp:159
virtual bool isTerminalMode() const
Check if the TPM is in terminal mode.
Definition: back-end.cpp:142
Represents an absolute name.
Definition: name.hpp:43
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
Check if the key with name keyName exists in the TPM.
Definition: back-end.cpp:39
unique_ptr< KeyHandle > getKeyHandle(const Name &keyName) const
Get the handle of the key with name keyName.
Definition: back-end.cpp:45
Base class of key parameters.
Definition: key-params.hpp:35
virtual bool isTpmLocked() const
Check if the TPM is locked.
Definition: back-end.cpp:153
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:126