NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
sec-tpm-file.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #ifndef NDN_SECURITY_SEC_TPM_FILE_HPP
27 #define NDN_SECURITY_SEC_TPM_FILE_HPP
28 
29 #include "../common.hpp"
30 
31 #include "sec-tpm.hpp"
32 
33 namespace ndn {
34 
35 class SecTpmFile : public SecTpm
36 {
37 public:
38  class Error : public SecTpm::Error
39  {
40  public:
41  explicit
42  Error(const std::string& what)
43  : SecTpm::Error(what)
44  {
45  }
46  };
47 
48  explicit
49  SecTpmFile(const std::string& dir = "");
50 
51  virtual
52  ~SecTpmFile();
53 
54  virtual void
55  setTpmPassword(const uint8_t* password, size_t passwordLength)
56  {
57  }
58 
59  virtual void
61  {
62  }
63 
64  virtual void
65  setInTerminal(bool inTerminal)
66  {
67  m_inTerminal = inTerminal;
68  }
69 
70  virtual bool
71  getInTerminal() const
72  {
73  return m_inTerminal;
74  }
75 
76  virtual bool
78  {
79  return false;
80  }
81 
82  virtual bool
83  unlockTpm(const char* password, size_t passwordLength, bool usePassword)
84  {
85  return !isLocked();
86  }
87 
88  virtual void
89  generateKeyPairInTpm(const Name& keyName, const KeyParams& params);
90 
91  virtual void
92  deleteKeyPairInTpm(const Name& keyName);
93 
94  virtual shared_ptr<PublicKey>
95  getPublicKeyFromTpm(const Name& keyName);
96 
97  virtual Block
98  signInTpm(const uint8_t* data, size_t dataLength,
99  const Name& keyName, DigestAlgorithm digestAlgorithm);
100 
101  virtual ConstBufferPtr
102  decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
103 
104  virtual ConstBufferPtr
105  encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
106 
107  virtual void
108  generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params);
109 
110  virtual bool
111  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
112 
113  virtual bool
114  generateRandomBlock(uint8_t* res, size_t size);
115 
116  virtual void
117  addAppToAcl(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl)
118  {
119  }
120 
121 protected:
123  // From TrustedPlatformModule //
125  virtual std::string
126  getScheme();
127 
128  virtual ConstBufferPtr
129  exportPrivateKeyPkcs8FromTpm(const Name& keyName);
130 
131  virtual bool
132  importPrivateKeyPkcs8IntoTpm(const Name& keyName, const uint8_t* buf, size_t size);
133 
134  virtual bool
135  importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buf, size_t size);
136 
137 public:
138  static const std::string SCHEME;
139 
140 private:
141  class Impl;
142  unique_ptr<Impl> m_impl;
143  bool m_inTerminal;
144 };
145 
146 } // namespace ndn
147 
148 #endif // NDN_SECURITY_SEC_TPM_FILE_HPP
Copyright (c) 2011-2015 Regents of the University of California.
virtual bool unlockTpm(const char *password, size_t passwordLength, bool usePassword)
Unlock the TPM.
virtual void addAppToAcl(const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)
Add the application into the ACL of a particular key.
virtual void resetTpmPassword()
reset password of TPM
Error(const std::string &what)
virtual bool doesKeyExistInTpm(const Name &keyName, KeyClass keyClass)
Check if a particular key exists.
virtual void setTpmPassword(const uint8_t *password, size_t passwordLength)
set password of TPM
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
SecTpmFile(const std::string &dir="")
static const std::string SCHEME
virtual void generateKeyPairInTpm(const Name &keyName, const KeyParams &params)
Generate a pair of asymmetric keys.
virtual void deleteKeyPairInTpm(const Name &keyName)
Delete a key pair of asymmetric keys.
virtual bool isLocked()
Check if TPM is locked.
virtual shared_ptr< PublicKey > getPublicKeyFromTpm(const Name &keyName)
Get a public key.
virtual ConstBufferPtr decryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
Decrypt data.
SecTpm is the base class of the TPM classes.
Definition: sec-tpm.hpp:41
virtual bool generateRandomBlock(uint8_t *res, size_t size)
Generate a random block.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
virtual ConstBufferPtr exportPrivateKeyPkcs8FromTpm(const Name &keyName)
Export a private key in PKCS#8 format.
virtual void setInTerminal(bool inTerminal)
Set inTerminal flag to.
virtual Block signInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)
Sign data.
virtual bool importPublicKeyPkcs1IntoTpm(const Name &keyName, const uint8_t *buf, size_t size)
Import a public key in PKCS#1 formatted.
virtual ConstBufferPtr encryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
Encrypt data.
virtual void generateSymmetricKeyInTpm(const Name &keyName, const KeyParams &params)
Generate a symmetric key.
Base class of key parameters.
Definition: key-params.hpp:35
virtual bool importPrivateKeyPkcs8IntoTpm(const Name &keyName, const uint8_t *buf, size_t size)
Import a private key from PKCS#8 formatted.
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
virtual bool getInTerminal() const
Get value of inTerminal flag.
virtual ~SecTpmFile()
virtual std::string getScheme()