All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
ndn::Producer Class Reference

A Producer manages content keys used to encrypt a data packet in the group-based encryption protocol. More...

#include <producer.hpp>

Public Types

typedef func_lib::function
< void(const std::vector
< ptr_lib::shared_ptr< Data >
> &keys)> 
OnEncryptedKeys
 

Public Member Functions

 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. More...
 
Name createContentKey (MillisecondsSince1970 timeSlot, const OnEncryptedKeys &onEncryptedKeys, const EncryptError::OnError &onError=defaultOnError)
 Create the content key corresponding to the timeSlot. More...
 
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 the encrypted content and an appropriate data name. More...
 

Static Public Member Functions

static void defaultOnError (EncryptError::ErrorCode errorCode, const std::string &message)
 The default OnError callback which does nothing.
 

Detailed Description

A Producer manages content keys used to encrypt a data packet in the group-based encryption protocol.

Note
This class is an experimental feature. The API may change.

Constructor & Destructor Documentation

ndn::Producer::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() 
)
inline

Create a Producer to use the given ProducerDb, Face and other values.

A producer can produce data with a naming convention: /{prefix}/SAMPLE/{dataType}/[timestamp]

The produced data packet is encrypted with a content key, which is stored in the ProducerDb database.

A producer also needs to produce data containing a content key encrypted with E-KEYs. A producer can retrieve E-KEYs through the face, and will re-try for at most repeatAttemps times when E-KEY retrieval fails.

Parameters
prefixThe producer name prefix. This makes a copy of the Name.
dataTypeThe dataType portion of the producer name. This makes a copy of the Name.
faceThe face used to retrieve keys. This is only a pointer to a Face object which must remain valid for the life of this Producer.
keyChainThe keyChain used to sign data packets. This is only a pointer to a KeyChain object which must remain valid for the life of this Producer.
databaseThe ProducerDb database for storing keys.
repeatAttempts(optional) The maximum retry for retrieving keys. If omitted, use 3.
keyRetrievalLink(optional) The Link object to use in Interests for key retrieval. This makes a copy of the Link object. If the Link object's getDelegations().size() is zero, don't use it. If omitted, don't use a Link object.

Member Function Documentation

Name ndn::Producer::createContentKey ( MillisecondsSince1970  timeSlot,
const OnEncryptedKeys &  onEncryptedKeys,
const EncryptError::OnError onError = defaultOnError 
)
inline

Create the content key corresponding to the timeSlot.

This first checks if the content key exists. For an existing content key, this returns the content key name directly. If the key does not exist, this creates one and encrypts it using the corresponding E-KEYs. The encrypted content keys are passed to the onEncryptedKeys callback.

Parameters
timeSlotThe time slot as milliseconds since Jan 1, 1970 UTC.
onEncryptedKeysIf this creates a content key, then this calls onEncryptedKeys(keys) where keys is a list of encrypted content key Data packets. If onEncryptedKeys is an empty OnEncryptedKeys(), this does not use it. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
onError(optional) This calls onError(errorCode, message) for an error. If omitted, use a default callback which does nothing. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.
Returns
The content key name.
void ndn::Producer::produce ( Data data,
MillisecondsSince1970  timeSlot,
const Blob content,
const EncryptError::OnError onError = defaultOnError 
)
inline

Encrypt the given content with the content key that covers timeSlot, and update the data packet with the encrypted content and an appropriate data name.

Parameters
dataAn empty Data object which is updated.
timeSlotThe time slot as milliseconds since Jan 1, 1970 UTC.
contentThe content to encrypt.
onError(optional) This calls onError(errorCode, message) for an error. If omitted, use a default callback which does nothing. NOTE: The library will log any exceptions thrown by this callback, but for better error handling the callback should catch and properly handle any exceptions.

The documentation for this class was generated from the following files: