NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
sec-tpm.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #ifndef NDN_SECURITY_SEC_TPM_HPP
25 #define NDN_SECURITY_SEC_TPM_HPP
26 
27 #include "../common.hpp"
28 #include "security-common.hpp"
29 #include "../name.hpp"
30 #include "../data.hpp"
31 #include "public-key.hpp"
32 #include "key-params.hpp"
33 
34 namespace ndn {
35 
41 class SecTpm : 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  explicit
55  SecTpm(const std::string& location);
56 
57  virtual
58  ~SecTpm();
59 
60  std::string
61  getTpmLocator();
62 
73  virtual void
74  setTpmPassword(const uint8_t* password, size_t passwordLength) = 0;
75 
79  virtual void
80  resetTpmPassword() = 0;
81 
88  virtual void
89  setInTerminal(bool inTerminal) = 0;
90 
94  virtual bool
95  getInTerminal() const = 0;
96 
100  virtual bool
101  isLocked() = 0;
102 
111  virtual bool
112  unlockTpm(const char* password, size_t passwordLength, bool usePassword) = 0;
113 
121  virtual void
122  generateKeyPairInTpm(const Name& keyName, const KeyParams& params) = 0;
123 
129  virtual void
130  deleteKeyPairInTpm(const Name& keyName) = 0;
131 
139  virtual shared_ptr<PublicKey>
140  getPublicKeyFromTpm(const Name& keyName) = 0;
141 
152  virtual Block
153  signInTpm(const uint8_t* data, size_t dataLength,
154  const Name& keyName,
155  DigestAlgorithm digestAlgorithm) = 0;
156 
167  virtual ConstBufferPtr
168  decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric) = 0;
169 
180  virtual ConstBufferPtr
181  encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric) = 0;
182 
190  virtual void
191  generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params) = 0;
192 
200  virtual bool
201  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass) = 0;
202 
210  virtual bool
211  generateRandomBlock(uint8_t* res, size_t size) = 0;
212 
221  virtual void
222  addAppToAcl(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl) = 0;
223 
233  exportPrivateKeyPkcs5FromTpm(const Name& keyName, const std::string& password);
234 
247  bool
248  importPrivateKeyPkcs5IntoTpm(const Name& keyName,
249  const uint8_t* buffer, size_t bufferSize,
250  const std::string& password);
251 
252 protected:
253  virtual std::string
254  getScheme() = 0;
255 
262  virtual ConstBufferPtr
263  exportPrivateKeyPkcs8FromTpm(const Name& keyName) = 0;
264 
274  virtual bool
275  importPrivateKeyPkcs8IntoTpm(const Name& keyName, const uint8_t* buffer, size_t bufferSize) = 0;
276 
286  virtual bool
287  importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buffer, size_t bufferSize) = 0;
288 
296  virtual bool
297  getImpExpPassWord(std::string& password, const std::string& prompt);
298 
299 protected:
300  std::string m_location;
301 };
302 
303 } // namespace ndn
304 
305 #endif // NDN_SECURITY_SEC_TPM_HPP
Copyright (c) 2011-2015 Regents of the University of California.
virtual ConstBufferPtr exportPrivateKeyPkcs8FromTpm(const Name &keyName)=0
Export a private key in PKCS#8 format.
std::string m_location
Definition: sec-tpm.hpp:300
std::string getTpmLocator()
Definition: sec-tpm.cpp:45
virtual void generateKeyPairInTpm(const Name &keyName, const KeyParams &params)=0
Generate a pair of asymmetric keys.
Error(const std::string &what)
Definition: sec-tpm.hpp:48
STL namespace.
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
virtual bool importPublicKeyPkcs1IntoTpm(const Name &keyName, const uint8_t *buffer, size_t bufferSize)=0
Import a public key in PKCS#1 formatted.
virtual void setTpmPassword(const uint8_t *password, size_t passwordLength)=0
set password of TPM
virtual bool generateRandomBlock(uint8_t *res, size_t size)=0
Generate a random block.
virtual ConstBufferPtr encryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)=0
Encrypt data.
virtual bool doesKeyExistInTpm(const Name &keyName, KeyClass keyClass)=0
Check if a particular key exists.
ConstBufferPtr exportPrivateKeyPkcs5FromTpm(const Name &keyName, const std::string &password)
Export a private key in PKCS#5 format.
Definition: sec-tpm.cpp:51
virtual void resetTpmPassword()=0
reset password of TPM
virtual shared_ptr< PublicKey > getPublicKeyFromTpm(const Name &keyName)=0
Get a public key.
SecTpm is the base class of the TPM classes.
Definition: sec-tpm.hpp:41
virtual bool isLocked()=0
Check if TPM is locked.
virtual void deleteKeyPairInTpm(const Name &keyName)=0
Delete a key pair of asymmetric keys.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
virtual bool getInTerminal() const =0
Get value of inTerminal flag.
bool importPrivateKeyPkcs5IntoTpm(const Name &keyName, const uint8_t *buffer, size_t bufferSize, const std::string &password)
Import a private key in PKCS#5 formatted.
Definition: sec-tpm.cpp:174
virtual bool getImpExpPassWord(std::string &password, const std::string &prompt)
Get import/export password.
Definition: sec-tpm.cpp:362
virtual ConstBufferPtr decryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)=0
Decrypt data.
virtual Block signInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)=0
Sign data.
virtual bool unlockTpm(const char *password, size_t passwordLength, bool usePassword)=0
Unlock the TPM.
virtual void generateSymmetricKeyInTpm(const Name &keyName, const KeyParams &params)=0
Generate a symmetric key.
Base class of key parameters.
Definition: key-params.hpp:35
virtual void addAppToAcl(const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)=0
Add the application into the ACL of a particular key.
virtual ~SecTpm()
Definition: sec-tpm.cpp:40
virtual bool importPrivateKeyPkcs8IntoTpm(const Name &keyName, const uint8_t *buffer, size_t bufferSize)=0
Import a private key from PKCS#8 formatted.
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
virtual std::string getScheme()=0
virtual void setInTerminal(bool inTerminal)=0
Set inTerminal flag to.
SecTpm(const std::string &location)
Definition: sec-tpm.cpp:35