new Producer(prefix, dataType, face, keyChain, database, repeatAttempts)
A Producer manages content keys used to encrypt a data packet in the
group-based encryption protocol.
Create a Producer to use the given ProducerDb, Face and other values.
A producer can produce data with a naming convention:
//SAMPLE//[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:
| Name | Type | Description |
|---|---|---|
prefix |
Name | The producer name prefix. This makes a copy of the Name. |
dataType |
Name | The dataType portion of the producer name. This makes a copy of the Name. |
face |
Face | The face used to retrieve keys. |
keyChain |
KeyChain | The keyChain used to sign data packets. |
database |
ProducerDb | The ProducerDb database for storing keys. |
repeatAttempts |
number | (optional) The maximum retry for retrieving keys. If omitted, use a default value of 3. |
- Source:
Methods
(static) excludeAfter(exclude, from)
Exclude all components in the range beginning at "from".
Parameters:
| Name | Type | Description |
|---|---|---|
exclude |
Exclude | The Exclude object to update. |
from |
Name.Component | The first component in the exclude range. |
- Source:
(static) excludeBefore(exclude, to)
Exclude all components in the range ending at "to".
Parameters:
| Name | Type | Description |
|---|---|---|
exclude |
Exclude | The Exclude object to update. |
to |
Name.Component | The last component in the exclude range. |
- Source:
(static) ExcludeEntry(component, anyFollowsComponent)
Create a new ExcludeEntry.
Parameters:
| Name | Type | Description |
|---|---|---|
component |
Name.Component | |
anyFollowsComponent |
boolean |
- Source:
(static) excludeRange(exclude, from, to)
Exclude all components in the range beginning at "from" and ending at "to".
Parameters:
| Name | Type | Description |
|---|---|---|
exclude |
Exclude | The Exclude object to update. |
from |
Name.Component | The first component in the exclude range. |
to |
Name.Component | The last component in the exclude range. |
- Source:
(static) findEntryBeforeOrAt(entries, component) → {number}
Get the latest entry in the array whose component_ is less than or equal to
component.
Parameters:
| Name | Type | Description |
|---|---|---|
entries |
Array.<ExcludeEntry> | The array of ExcludeEntry. |
component |
Name.Component | The component to compare. |
- Source:
Returns:
The index of the found entry, or -1 if not found.
- Type
- number
(static) getExcludeEntries(exclude) → {Array.<ExcludeEntry>}
Create a list of ExcludeEntry from the Exclude object.
Parameters:
| Name | Type | Description |
|---|---|---|
exclude |
Exclude | The Exclude object to read. |
- Source:
Returns:
A new array of ExcludeEntry.
- Type
- Array.<ExcludeEntry>
(static) getRoundedTimeSlot_(timeSlot) → {number}
Round timeSlot to the nearest whole hour, so that we can store content keys
uniformly (by start of the hour).
Parameters:
| Name | Type | Description |
|---|---|---|
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
- Source:
Returns:
The start of the hour as milliseconds since Jan 1, 1970 UTC.
- Type
- number
(static) setExcludeEntries(exclude, entries)
Set the Exclude object from the array of ExcludeEntry.
Parameters:
| Name | Type | Description |
|---|---|---|
exclude |
Exclude | The Exclude object to update. |
entries |
Array.<ExcludeEntry> | The array of ExcludeEntry. |
- Source:
createContentKey(timeSlot, onEncryptedKeys, onContentKeyName)
Create the content key. 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
onProducerEKey callback.
Parameters:
| Name | Type | Description |
|---|---|---|
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
onEncryptedKeys |
function | 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 null, this does not use it. |
onContentKeyName |
function | This calls onContentKeyName(contentKeyName) with the content key name for the time slot. If onContentKeyName is null, this does not use it. (A callback is neede because of async database operations.) |
- Source:
encryptContentKey_(keyRequest, encryptionKey, eKeyName, timeSlot, onEncryptedKeys)
Get the content key from the database_ and encrypt it for the timeSlot
using encryptionKey.
Parameters:
| Name | Type | Description |
|---|---|---|
keyRequest |
Producer.KeyRequest_ | The KeyRequest which is updated. |
encryptionKey |
Blob | The encryption key value. |
eKeyName |
Name | The key name for the EncryptedContent. |
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
onEncryptedKeys |
function | When there are no more interests to process, this calls onEncryptedKeys(keys) where keys is a list of encrypted content key Data packets. If onEncryptedKeys is null, this does not use it. |
- Source:
handleCoveringKey_(interest, data, timeSlot, keyRequest, onEncryptedKeys)
This is called from an expressInterest OnData to check that the encryption
key contained in data fits the timeSlot. This sends a refined interest if
required.
Parameters:
| Name | Type | Description |
|---|---|---|
interest |
Interest | The interest given to expressInterest. |
data |
Data | The fetched Data packet. |
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
keyRequest |
Producer.KeyRequest_ | The KeyRequest which is updated. |
onEncryptedKeys |
function | When there are no more interests to process, this calls onEncryptedKeys(keys) where keys is a list of encrypted content key Data packets. If onEncryptedKeys is null, this does not use it. |
- Source:
handleTimeout_(interest, timeSlot, keyRequest, onEncryptedKeys)
This is called from an expressInterest timeout to update the state of
keyRequest.
Parameters:
| Name | Type | Description |
|---|---|---|
interest |
Interest | The timed-out interest. |
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
keyRequest |
Producer.KeyRequest_ | The KeyRequest which is updated. |
onEncryptedKeys |
function | When there are no more interests to process, this calls onEncryptedKeys(keys) where keys is a list of encrypted content key Data packets. If onEncryptedKeys is null, this does not use it. |
- Source:
produce(data, timeSlot, content, onComplete, onError)
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:
| Name | Type | Description |
|---|---|---|
data |
Data | An empty Data object which is updated. |
timeSlot |
number | The time slot as milliseconds since Jan 1, 1970 UTC. |
content |
Blob | The content to encrypt. |
onComplete |
function | This calls onComplete() when the data packet has been updated. |
onError |
function | (optional) If there is an exception, then this calls onError(exception) with the exception. If omitted, this does not use it. |
- Source:
sendKeyInterest_(name, timeSlot, keyRequest, onEncryptedKeys, timeRange)
Send an interest with the given name through the face with callbacks to
handleCoveringKey_ and handleTimeout_.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
Name | The name of the interest to send. |
timeSlot |
number | The time slot, passed to handleCoveringKey_ and handleTimeout_. |
keyRequest |
Producer.KeyRequest_ | The KeyRequest, passed to handleCoveringKey_ and handleTimeout_. |
onEncryptedKeys |
function | The OnEncryptedKeys callback, passed to handleCoveringKey_ and handleTimeout_. |
timeRange |
Exclude | The Exclude for the interest. |
- Source: