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. | |
A Producer manages content keys used to encrypt a data packet in the group-based encryption protocol.
|
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.
| prefix | The producer name prefix. This makes a copy of the Name. |
| dataType | The dataType portion of the producer name. This makes a copy of the Name. |
| face | The face used to retrieve keys. This is only a pointer to a Face object which must remain valid for the life of this Producer. |
| keyChain | The 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. |
| database | The 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. |
|
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.
| timeSlot | The time slot as milliseconds since Jan 1, 1970 UTC. |
| onEncryptedKeys | If 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. |
|
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.
| data | An empty Data object which is updated. |
| timeSlot | The time slot as milliseconds since Jan 1, 1970 UTC. |
| content | The 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. |
1.8.6