23 #ifndef NDN_CONSUMER_HPP
24 #define NDN_CONSUMER_HPP
27 #include "../data.hpp"
28 #include "../face.hpp"
29 #include "../security/key-chain.hpp"
30 #include "encrypt-error.hpp"
31 #include "encrypted-content.hpp"
32 #include "consumer-db.hpp"
35 class TestConsumer_DecryptContent_Test;
70 const Name& consumerName,
const ptr_lib::shared_ptr<ConsumerDb>& database,
71 const Link& cKeyLink = getNO_LINK(),
const Link& dKeyLink = getNO_LINK())
73 (face, keyChain, groupName, consumerName, database, cKeyLink, dKeyLink))
77 typedef func_lib::function<void
78 (
const ptr_lib::shared_ptr<Data>& contentData,
79 const Blob& result)> OnConsumeComplete;
81 typedef func_lib::function<void(const Blob& decryptedBlob)> OnPlainText;
104 (
const Name& contentName,
const OnConsumeComplete& onConsumeComplete,
107 impl_->consume(contentName, onConsumeComplete, onError, link);
129 impl_->addDecryptionKey(keyName, keyBlob);
143 (
const Data& data,
const OnPlainText& onPlainText,
151 friend TestConsumer_DecryptContent_Test;
157 class Impl :
public ptr_lib::enable_shared_from_this<Impl> {
165 const Name& consumerName,
const ptr_lib::shared_ptr<ConsumerDb>& database,
166 const Link& cKeyLink,
const Link& dKeyLink);
170 (
const Name& contentName,
const OnConsumeComplete& onConsumeComplete,
174 setGroup(
const Name& groupName) { groupName_ = groupName; }
181 (
const Data& data,
const OnPlainText& onPlainText,
186 friend TestConsumer_DecryptContent_Test;
198 (
const Blob& encryptedBlob,
const Blob& keyBits,
210 decryptEncryptedContent
211 (
const EncryptedContent& encryptedContent,
const Blob& keyBits,
223 (
const Data& cKeyData,
const OnPlainText& onPlainText,
235 (
const Data& dKeyData,
const OnPlainText& onPlainText,
247 getDecryptionKey(
const Name& decryptionKeyName)
249 return database_->getKey(decryptionKeyName);
270 (
const ptr_lib::shared_ptr<const Interest>& interest,
int nRetrials,
271 const ptr_lib::shared_ptr<Link>& link,
const OnVerified& onVerified,
280 (
const ptr_lib::shared_ptr<Data>& data,
const std::string& reason,
283 ptr_lib::shared_ptr<ConsumerDb> database_;
289 const ptr_lib::shared_ptr<Link> cKeyLink_;
291 std::map<Name, Blob> cKeyMap_;
292 const ptr_lib::shared_ptr<Link> dKeyLink_;
294 std::map<Name, Blob> dKeyMap_;
306 noLink_ =
new Link();
311 ptr_lib::shared_ptr<Impl> impl_;
312 static Link* noLink_;
The Face class provides the main methods for NDN communication.
Definition: face.hpp:86
func_lib::function< void(ErrorCode errorCode, const std::string &message)> OnError
A method calls onError(errorCode, message) for an error.
Definition: encrypt-error.hpp:50
func_lib::function< void(const ptr_lib::shared_ptr< Data > &data)> OnVerified
An OnVerified function object is used to pass a callback to verifyData to report a successful verific...
Definition: validation-request.hpp:33
KeyChain is the main class of the security library.
Definition: key-chain.hpp:53
A Consumer manages fetched group keys used to decrypt a data packet in the group-based encryption pro...
Definition: consumer.hpp:44
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
void setGroup(const Name &groupName)
Set the group name.
Definition: consumer.hpp:116
Consumer(Face *face, KeyChain *keyChain, const Name &groupName, const Name &consumerName, const ptr_lib::shared_ptr< ConsumerDb > &database, const Link &cKeyLink=getNO_LINK(), const Link &dKeyLink=getNO_LINK())
Create a Consumer to use the given ConsumerDb, Face and other values.
Definition: consumer.hpp:69
void addDecryptionKey(const Name &keyName, const Blob &keyBlob)
Add a new decryption key with keyName and keyBlob to the database.
Definition: consumer.hpp:127
void consume(const Name &contentName, const OnConsumeComplete &onConsumeComplete, const EncryptError::OnError &onError, const Link &link=getNO_LINK())
Express an Interest to fetch the content packet with contentName, and decrypt it, fetching keys as ne...
Definition: consumer.hpp:104
The Link class extends Data and represents a Link instance where the Data content is an encoded deleg...
Definition: link.hpp:35
void decryptContent(const Data &data, const OnPlainText &onPlainText, const EncryptError::OnError &onError)
A utility method to decrypt the data packet, retrieving the C-KEY Data from the network if necessary...
Definition: consumer.hpp:143