24 #ifndef NDN_PRODUCER_HPP
25 #define NDN_PRODUCER_HPP
28 #include "../face.hpp"
29 #include "../security/key-chain.hpp"
30 #include "encrypt-error.hpp"
31 #include "producer-db.hpp"
42 typedef func_lib::function<
43 void(
const std::vector<ptr_lib::shared_ptr<Data> >& keys)> OnEncryptedKeys;
75 const ptr_lib::shared_ptr<ProducerDb>& database,
int repeatAttempts = 3,
76 const Link& keyRetrievalLink = getNO_LINK())
78 (prefix, dataType, face, keyChain, database, repeatAttempts,
109 return impl_->createContentKey(timeSlot, onEncryptedKeys, onError);
130 impl_->produce(data, timeSlot, content, onError);
137 defaultOnError(EncryptError::ErrorCode errorCode,
const std::string& message);
144 class Impl :
public ptr_lib::enable_shared_from_this<Impl> {
152 const ptr_lib::shared_ptr<ProducerDb>& database,
int repeatAttempts,
153 const Link& keyRetrievalLink);
168 KeyInfo() : beginTimeSlot(0), endTimeSlot(0) {}
177 KeyRequest(
int interests)
179 interestCount = interests;
183 std::map<Name, int> repeatAttempts;
184 std::vector<ptr_lib::shared_ptr<Data> > encryptedKeys;
208 const OnEncryptedKeys& onEncryptedKeys,
224 (
const ptr_lib::shared_ptr<const Interest>& interest,
243 (
const ptr_lib::shared_ptr<const Interest>& interest,
244 const ptr_lib::shared_ptr<NetworkNack>& networkNack,
246 const OnEncryptedKeys& onEncryptedKeys,
261 (
const ptr_lib::shared_ptr<KeyRequest>& keyRequest,
278 (
const ptr_lib::shared_ptr<const Interest>& interest,
280 const OnEncryptedKeys& onEncryptedKeys,
297 (
const Blob& encryptionKey,
const Name& eKeyName,
304 ExcludeEntry(
const Name::Component& component,
bool anyFollowsComponent)
305 : component_(component), anyFollowsComponent_(anyFollowsComponent)
309 Name::Component component_;
310 bool anyFollowsComponent_;
319 getExcludeEntries(
const Exclude& exclude, std::vector<ExcludeEntry>& entries);
327 setExcludeEntries(Exclude& exclude,
const std::vector<ExcludeEntry>& entries);
338 (
const std::vector<ExcludeEntry>& entries,
339 const Name::Component& component);
347 excludeAfter(Exclude& exclude,
const Name::Component& from);
355 excludeBefore(Exclude& exclude,
const Name::Component& to)
357 excludeRange(exclude, Name::Component(), to);
368 (Exclude& exclude,
const Name::Component& from,
const Name::Component& to);
373 std::map<Name, ptr_lib::shared_ptr<KeyInfo> > eKeyInfo_;
374 std::map<MillisecondsSince1970, ptr_lib::shared_ptr<KeyRequest> > keyRequests_;
375 ptr_lib::shared_ptr<ProducerDb> database_;
376 int maxRepeatAttempts_;
378 Link keyRetrievalLink_;
380 static const int START_TIME_STAMP_INDEX = -2;
381 static const int END_TIME_STAMP_INDEX = -1;
393 noLink_ =
new Link();
398 ptr_lib::shared_ptr<Impl> impl_;
399 static Link* noLink_;
A Producer manages content keys used to encrypt a data packet in the group-based encryption protocol...
Definition: producer.hpp:40
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
Producer(const Name &prefix, const Name &dataType, Face *face, KeyChain *keyChain, const ptr_lib::shared_ptr< ProducerDb > &database, int repeatAttempts=3, const Link &keyRetrievalLink=getNO_LINK())
Create a Producer to use the given ProducerDb, Face and other values.
Definition: producer.hpp:74
void produce(Data &data, MillisecondsSince1970 timeSlot, const Blob &content, const EncryptError::OnError &onError=defaultOnError)
Encrypt the given content with the content key that covers timeSlot, and update the data packet with ...
Definition: producer.hpp:127
KeyChain is the main class of the security library.
Definition: key-chain.hpp:53
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
double MillisecondsSince1970
The calendar time represented as the number of milliseconds since 1/1/1970.
Definition: common.hpp:119
static void defaultOnError(EncryptError::ErrorCode errorCode, const std::string &message)
The default OnError callback which does nothing.
Definition: producer.cpp:37
The Link class extends Data and represents a Link instance where the Data content is an encoded deleg...
Definition: link.hpp:35
Name createContentKey(MillisecondsSince1970 timeSlot, const OnEncryptedKeys &onEncryptedKeys, const EncryptError::OnError &onError=defaultOnError)
Create the content key corresponding to the timeSlot.
Definition: producer.hpp:106