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