NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 
25 namespace ndn {
26 namespace security {
27 
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
132  resetTpmPassword();
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)
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.
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.
SecTpm is the base class of the TPM classes.
Definition: sec-tpm.hpp:41
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.
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.
SecPublicInfo is a base class for the storage of public information.
virtual void addCertificate(const IdentityCertificate &certificate)
Add a certificate to the identity storage.
virtual void setDefaultIdentityInternal(const Name &identityName)
Set the default identity.