NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
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 #include <ndn-cxx/security/security-common.hpp>
25 
26 namespace ndn {
27 namespace security {
28 
30 public:
31  DummyPublicInfo(const std::string& locator);
32 
33  virtual bool
34  doesIdentityExist(const Name& identityName);
35 
36  virtual void
37  addIdentity(const Name& identityName);
38 
39  virtual bool
41 
42  virtual bool
43  doesPublicKeyExist(const Name& keyName);
44 
45  virtual void
46  addKey(const Name& keyName, const PublicKey& publicKey);
47 
48  virtual shared_ptr<PublicKey>
49  getPublicKey(const Name& keyName);
50 
51  virtual KeyType
52  getPublicKeyType(const Name& keyName);
53 
54  virtual bool
55  doesCertificateExist(const Name& certificateName);
56 
57  virtual void
58  addCertificate(const IdentityCertificate& certificate);
59 
60  virtual shared_ptr<IdentityCertificate>
61  getCertificate(const Name& certificateName);
62 
63  virtual Name
65 
66  virtual Name
67  getDefaultKeyNameForIdentity(const Name& identityName);
68 
69  virtual Name
70  getDefaultCertificateNameForKey(const Name& keyName);
71 
72  virtual void
73  getAllIdentities(std::vector<Name>& nameList, bool isDefault);
74 
75  virtual void
76  getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
77 
78  virtual void
79  getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
80 
81  virtual void
82  getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
83 
84  virtual void
85  getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
86 
87  virtual void
88  deleteCertificateInfo(const Name& certificateName);
89 
90  virtual void
91  deletePublicKeyInfo(const Name& keyName);
92 
93  virtual void
94  deleteIdentityInfo(const Name& identity);
95 
96  virtual void
97  setTpmLocator(const std::string& tpmLocator);
98 
99  virtual std::string
100  getTpmLocator();
101 
102 protected:
103  virtual void
104  setDefaultIdentityInternal(const Name& identityName);
105 
106  virtual void
108 
109  virtual void
110  setDefaultCertificateNameForKeyInternal(const Name& certificateName);
111 
112  virtual std::string
113  getScheme();
114 
115 public:
116  static const std::string SCHEME;
117 
118 private:
119  std::string m_tpmLocator;
120 };
121 
124 
125 class DummyTpm : public SecTpm {
126 public:
127  DummyTpm(const std::string& locator);
128 
129  virtual void
130  setTpmPassword(const uint8_t* password, size_t passwordLength);
131 
132  virtual void
133  resetTpmPassword();
134 
135  virtual void
136  setInTerminal(bool inTerminal);
137 
138  virtual bool
139  getInTerminal() const;
140 
141  virtual bool
142  isLocked();
143 
144  virtual bool
145  unlockTpm(const char* password, size_t passwordLength, bool usePassword);
146 
147  virtual void
148  generateKeyPairInTpm(const Name& keyName, const KeyParams& params);
149 
150  virtual void
151  deleteKeyPairInTpm(const Name& keyName);
152 
153  virtual shared_ptr<PublicKey>
154  getPublicKeyFromTpm(const Name& keyName);
155 
156  virtual Block
157  signInTpm(const uint8_t* data, size_t dataLength, const Name& keyName,
158  DigestAlgorithm digestAlgorithm);
159 
160  virtual ConstBufferPtr
161  decryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
162 
163  virtual ConstBufferPtr
164  encryptInTpm(const uint8_t* data, size_t dataLength, const Name& keyName, bool isSymmetric);
165 
166  virtual void
167  generateSymmetricKeyInTpm(const Name& keyName, const KeyParams& params);
168 
169  virtual bool
170  doesKeyExistInTpm(const Name& keyName, KeyClass keyClass);
171 
172  virtual bool
173  generateRandomBlock(uint8_t* res, size_t size);
174 
175  virtual void
176  addAppToAcl(const Name& keyName, KeyClass keyClass, const std::string& appPath, AclType acl);
177 
178  virtual std::string
179  getScheme();
180 
181 protected:
182  virtual ConstBufferPtr
183  exportPrivateKeyPkcs8FromTpm(const Name& keyName);
184 
185  virtual bool
186  importPrivateKeyPkcs8IntoTpm(const Name& keyName, const uint8_t* buffer, size_t bufferSize);
187 
188  virtual bool
189  importPublicKeyPkcs1IntoTpm(const Name& keyName, const uint8_t* buffer, size_t bufferSize);
190 
191 public:
192  static const std::string SCHEME;
193 };
194 
195 } // namespace security
196 } // namespace ndn
197 
198 #endif // NDNSIM_UTILS_DUMMY_KEYCHAIN_HPP
virtual shared_ptr< PublicKey > getPublicKey(const Name &keyName)
Get shared pointer to PublicKey object from the identity storage.
virtual Name getDefaultCertificateNameForKey(const Name &keyName)
Get name of the default certificate name for the specified key.
Copyright (c) 2011-2015 Regents of the University of California.
virtual void deleteCertificateInfo(const Name &certificateName)
Delete a certificate.
static const std::string SCHEME
virtual void deleteIdentityInfo(const Name &identity)
Delete an identity and related public keys and certificates.
virtual KeyType getPublicKeyType(const Name &keyName)
Get the type of the queried public key.
virtual shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName)
Get a shared pointer to identity certificate object from the identity storage.
virtual void getAllKeyNames(std::vector< Name > &nameList, bool isDefault)
Get all the key names from public info.
SecTpm is the base class of the TPM classes.
Definition: sec-tpm.hpp:42
virtual void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
DummyPublicInfo(const std::string &locator)
virtual bool revokeIdentity()
Revoke the identity.
virtual void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault)
Get all the key names of a particular identity.
virtual std::string getScheme()
return the scheme of the PibLocator
virtual bool doesPublicKeyExist(const Name &keyName)
Check if the specified key already exists.
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)
Get all the identities from public info.
static const std::string SCHEME
virtual Name getDefaultIdentity()
Get name of the default identity.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
virtual void setDefaultKeyNameForIdentityInternal(const Name &keyName)
Set the default key name for the corresponding identity.
virtual void addKey(const Name &keyName, const PublicKey &publicKey)
Add a public key to the identity storage.
virtual bool doesCertificateExist(const Name &certificateName)
Check if the specified certificate already exists.
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)
Get all the certificate name of a particular key name.
virtual void deletePublicKeyInfo(const Name &keyName)
Delete a public key and related certificates.
SecPublicInfo is a base class for the storage of public information.
virtual void addIdentity(const Name &identityName)
Add a new identity.
virtual void setDefaultCertificateNameForKeyInternal(const Name &certificateName)
Set the default certificate name for the corresponding key.
Base class of key parameters.
Definition: key-params.hpp:35
virtual bool doesIdentityExist(const Name &identityName)
Check if the specified identity already exists.
virtual void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault)
Get all the certificate name in public info.
shared_ptr< const Buffer > ConstBufferPtr
Definition: buffer.hpp:33
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)
Get name of the default key name for the specified identity.
virtual std::string getTpmLocator()
Get TPM Locator.
virtual void addCertificate(const IdentityCertificate &certificate)
Add a certificate to the identity storage.
virtual void setDefaultIdentityInternal(const Name &identityName)
Set the default identity.