NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dummy-keychain.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
20 #ifndef NDNSIM_UTILS_DUMMY_KEYCHAIN_HPP
21 #define NDNSIM_UTILS_DUMMY_KEYCHAIN_HPP
22 
23 #include <ndn-cxx/security/key-chain.hpp>
24 
25 namespace ndn {
26 namespace security {
27 
28 class DummyPublicInfo : public SecPublicInfo {
29 public:
30  DummyPublicInfo(const std::string& locator);
31 
32  virtual bool
33  doesIdentityExist(const Name& identityName);
34 
35  virtual void
36  addIdentity(const Name& identityName);
37 
38  virtual bool
40 
41  virtual bool
42  doesPublicKeyExist(const Name& keyName);
43 
44  virtual void
45  addKey(const Name& keyName, const PublicKey& publicKey);
46 
47  virtual shared_ptr<PublicKey>
48  getPublicKey(const Name& keyName);
49 
50  virtual KeyType
51  getPublicKeyType(const Name& keyName);
52 
53  virtual bool
54  doesCertificateExist(const Name& certificateName);
55 
56  virtual void
57  addCertificate(const IdentityCertificate& certificate);
58 
59  virtual shared_ptr<IdentityCertificate>
60  getCertificate(const Name& certificateName);
61 
62  virtual Name
64 
65  virtual Name
66  getDefaultKeyNameForIdentity(const Name& identityName);
67 
68  virtual Name
69  getDefaultCertificateNameForKey(const Name& keyName);
70 
71  virtual void
72  getAllIdentities(std::vector<Name>& nameList, bool isDefault);
73 
74  virtual void
75  getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
76 
77  virtual void
78  getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
79 
80  virtual void
81  getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
82 
83  virtual void
84  getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
85 
86  virtual void
87  deleteCertificateInfo(const Name& certificateName);
88 
89  virtual void
90  deletePublicKeyInfo(const Name& keyName);
91 
92  virtual void
93  deleteIdentityInfo(const Name& identity);
94 
95  virtual void
96  setTpmLocator(const std::string& tpmLocator);
97 
98  virtual std::string
99  getTpmLocator();
100 
101 protected:
102  virtual void
103  setDefaultIdentityInternal(const Name& identityName);
104 
105  virtual void
107 
108  virtual void
109  setDefaultCertificateNameForKeyInternal(const Name& certificateName);
110 
111  virtual std::string
112  getScheme();
113 
114 public:
115  static const std::string SCHEME;
116 
117 private:
118  std::string m_tpmLocator;
119 };
120 
123 
124 class DummyTpm : public SecTpm {
125 public:
126  DummyTpm(const std::string& locator);
127 
128  virtual void
129  setTpmPassword(const uint8_t* password, size_t passwordLength);
130 
131  virtual void
133 
134  virtual void
135  setInTerminal(bool inTerminal);
136 
137  virtual bool
138  getInTerminal() const;
139 
140  virtual bool
141  isLocked();
142 
143  virtual bool
144  unlockTpm(const char* password, size_t passwordLength, bool usePassword);
145 
146  virtual void
147  generateKeyPairInTpm(const Name& keyName, const KeyParams& params);
148 
149  virtual void
150  deleteKeyPairInTpm(const Name& keyName);
151 
152  virtual shared_ptr<PublicKey>
153  getPublicKeyFromTpm(const Name& keyName);
154 
155  virtual Block
156  signInTpm(const uint8_t* data, size_t dataLength, const Name& keyName,
157  DigestAlgorithm digestAlgorithm);
158 
159  virtual ConstBufferPtr
160  decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
161 
162  virtual ConstBufferPtr
163  encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
164 
165  virtual void
166  generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params);
167 
168  virtual bool
169  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
170 
171  virtual bool
172  generateRandomBlock(uint8_t* res, size_t size);
173 
174  virtual void
175  addAppToAcl(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl);
176 
177  virtual std::string
178  getScheme();
179 
180 protected:
181  virtual ConstBufferPtr
182  exportPrivateKeyPkcs8FromTpm(const Name& keyName);
183 
184  virtual bool
185  importPrivateKeyPkcs8IntoTpm(const Name& keyName, const uint8_t* buffer, size_t bufferSize);
186 
187  virtual bool
188  importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buffer, size_t bufferSize);
189 
190 public:
191  static const std::string SCHEME;
192 };
193 
194 } // namespace security
195 } // namespace ndn
196 
197 #endif // NDNSIM_UTILS_DUMMY_KEYCHAIN_HPP
virtual shared_ptr< PublicKey > getPublicKey(const Name &keyName)
virtual bool generateRandomBlock(uint8_t *res, size_t size)
virtual Name getDefaultCertificateNameForKey(const Name &keyName)
virtual void deleteKeyPairInTpm(const Name &keyName)
virtual void deleteCertificateInfo(const Name &certificateName)
static const std::string SCHEME
virtual bool unlockTpm(const char *password, size_t passwordLength, bool usePassword)
virtual ConstBufferPtr exportPrivateKeyPkcs8FromTpm(const Name &keyName)
virtual void deleteIdentityInfo(const Name &identity)
virtual bool doesKeyExistInTpm(const Name &keyName, KeyClass keyClass)
virtual KeyType getPublicKeyType(const Name &keyName)
virtual shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName)
virtual void getAllKeyNames(std::vector< Name > &nameList, bool isDefault)
virtual void setTpmLocator(const std::string &tpmLocator)
virtual bool getInTerminal() const
virtual void resetTpmPassword()
DummyPublicInfo(const std::string &locator)
virtual void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault)
virtual std::string getScheme()
virtual shared_ptr< PublicKey > getPublicKeyFromTpm(const Name &keyName)
virtual bool doesPublicKeyExist(const Name &keyName)
virtual ConstBufferPtr encryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)
static const std::string SCHEME
virtual std::string getScheme()
virtual ConstBufferPtr decryptInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, bool isSymmetric)
virtual void setDefaultKeyNameForIdentityInternal(const Name &keyName)
virtual void addKey(const Name &keyName, const PublicKey &publicKey)
virtual bool doesCertificateExist(const Name &certificateName)
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)
virtual Block signInTpm(const uint8_t *data, size_t dataLength, const Name &keyName, DigestAlgorithm digestAlgorithm)
virtual void deletePublicKeyInfo(const Name &keyName)
virtual void addAppToAcl(const Name &keyName, KeyClass keyClass, const std::string &appPath, AclType acl)
virtual void setInTerminal(bool inTerminal)
virtual void addIdentity(const Name &identityName)
DummyTpm(const std::string &locator)
virtual void setDefaultCertificateNameForKeyInternal(const Name &certificateName)
virtual void generateKeyPairInTpm(const Name &keyName, const KeyParams &params)
virtual bool importPublicKeyPkcs1IntoTpm(const Name &keyName, const uint8_t *buffer, size_t bufferSize)
virtual bool doesIdentityExist(const Name &identityName)
virtual void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault)
virtual bool importPrivateKeyPkcs8IntoTpm(const Name &keyName, const uint8_t *buffer, size_t bufferSize)
virtual void setTpmPassword(const uint8_t *password, size_t passwordLength)
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)
virtual std::string getTpmLocator()
virtual void generateSymmetricKeyInTpm(const Name &keyName, const KeyParams &params)
virtual void addCertificate(const IdentityCertificate &certificate)
virtual void setDefaultIdentityInternal(const Name &identityName)