This module defines the Consumer class which manages fetched group keys used to decrypt a data packet in the group-based encryption protocol. Note: This class is an experimental feature. The API may change.
Bases: object
Create a Consumer to use the given ConsumerDb, Face and other values.
Parameters: |
|
---|
Add a new decryption key with keyName and keyBlob to the database.
Parameters: |
|
---|---|
Raises: |
|
Express an Interest to fetch the content packet with contentName, and decrypt it, fetching keys as needed.
Parameters: |
|
---|
This module defines the ConsumerDb class which is an abstract base class the storage of decryption keys for the consumer. A subclass must implement the methods. For example, see Sqlite3ConsumerDb. Note: This class is an experimental feature. The API may change.
Bases: object
Add the key with keyName and keyBlob to the database.
Parameters: |
|
---|---|
Raises ConsumerDb.Error: | |
If a key with the same keyName already exists in the database, or other database error. |
This module defines the EncryptKey class which supplies the key for decrypt. Note: This class is an experimental feature. The API may change.
This module defines the EncryptError class which is used as a namespace to hold the ErrorCode enum for errors from the encrypt library. In the future it may hold more enums or functions.
This module defines the EncryptKey class which supplies the key for encrypt. Note: This class is an experimental feature. The API may change.
This module defines the EncryptedContent class which holds an encryption type, a payload and other fields representing encrypted content. Note: This class is an experimental feature. The API may change.
Bases: object
Create an EncryptedContent.
Parameters: | value (EncryptedContent) – (optional) If value is another EncryptedContent then copy it. If value is omitted then create an EncryptedContent with unspecified values. |
---|
Get the algorithm type from EncryptAlgorithmType.
Returns: | The algorithm type from EncryptAlgorithmType, or None if not specified. |
---|---|
Return type: | int |
Get the initial vector.
Returns: | The initial vector. If not specified, isNull() is True. |
---|---|
Return type: | Blob |
Get the key locator.
Returns: | The key locator. If not specified, getType() is None. |
---|---|
Return type: | KeyLocator |
Get the payload.
Returns: | The payload. If not specified, isNull() is True. |
---|---|
Return type: | Blob |
Set the algorithm type.
Parameters: | algorithmType (int) – The algorithm type from EncryptAlgorithmType. If not specified, set to None. |
---|---|
Returns: | This EncryptedContent so that you can chain calls to update values. |
Return type: | EncryptedContent |
Set the initial vector.
Parameters: | initialVector (Blob) – The initial vector. If not specified, set to the default Blob() where isNull() is True. |
---|---|
Returns: | This EncryptedContent so that you can chain calls to update values. |
Return type: | EncryptedContent |
Set the key locator.
Parameters: | keyLocator (KeyLocator) – The key locator. This makes a copy of the object. If not specified, set to the default KeyLocator(). |
---|---|
Returns: | This EncryptedContent so that you can chain calls to update values. |
Return type: | EncryptedContent |
Set the encrypted payload.
Parameters: | payload (Blob) – The payload. If not specified, set to the default Blob() where isNull() is True. |
---|---|
Returns: | This EncryptedContent so that you can chain calls to update values. |
Return type: | EncryptedContent |
Decode the input using a particular wire format and update this EncryptedContent.
Parameters: |
|
---|
Encode this EncryptedContent for a particular wire format.
Parameters: | wireFormat (A subclass of WireFormat) – (optional) A WireFormat object used to encode this EncryptedContent. If omitted, use WireFormat.getDefaultWireFormat(). |
---|---|
Returns: | The encoded buffer. |
Return type: | Blob |
This module defines the GroupManager class which manages keys and schedules for group members in a particular namespace. Note: This class is an experimental feature. The API may change.
Bases: object
Create a GroupManager with the given values. The group manager namespace is <prefix>/read/<dataType> .
Parameters: |
|
---|
Add a new member with the given memberCertificate into a schedule named scheduleName. If cert is an IdentityCertificate made from memberCertificate, then the member’s identity name is cert.getPublicKeyName().getPrefix(-1).
Parameters: |
|
---|---|
Raises: |
|
Add a schedule with the given scheduleName.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If a schedule with the same name already exists, if the name is empty, or other database error. |
Delete the schedule with the given scheduleName. Also delete members which use this schedule. If there is no schedule with the name, then do nothing.
Parameters: | scheduleName (str) – The name of the schedule. |
---|---|
Raises GroupManagerDb.Error: | |
For a database error. |
Create a group key for the interval into which timeSlot falls. This creates a group key if it doesn’t exist, and encrypts the key using the public key of each eligible member.
Parameters: | timeSlot (float) – The time slot to cover as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | A List of Data packets where the first is the E-KEY data packet with the group’s public key and the rest are the D-KEY data packets with the group’s private key encrypted with the public key of each eligible member. |
Raises: |
|
Remove a member with the given identity name. If there is no member with the identity name, then do nothing.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Raises GroupManagerDb.Error: | |
For a database error. |
Change the name of the schedule for the given member’s identity name.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If there’s no member with the given identity name in the database, or there’s no schedule named scheduleName. |
Update the schedule with scheduleName and replace the old object with the given schedule. Otherwise, if no schedule with name exists, a new schedule with name and the given schedule will be added to database.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If the name is empty, or other database error. |
This module defines the GroupManagerDb class which is an abstract base class for the storage of data used by the GroupManager. It contains two tables to store Schedules and Members. This is an abstract base class. A subclass must implement the methods. For example, see Sqlite3GroupManagerDb. Note: This class is an experimental feature. The API may change.
Bases: object
Add a new member with the given key named keyName into a schedule named scheduleName. The member’s identity name is keyName.getPrefix(-1).
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If there’s no schedule named scheduleName, if the member’s identity name already exists, or other database error. |
Add a schedule with the given name.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If a schedule with the same name already exists, if the name is empty, or other database error. |
Delete a member with the given identity name. If there is no member with the identity name, then do nothing.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Raises GroupManagerDb.Error: | |
For a database error. |
Delete the schedule with the given name. Also delete members which use this schedule. If there is no schedule with the name, then do nothing.
Parameters: | name (str) – The name of the schedule. |
---|---|
Raises GroupManagerDb.Error: | |
For a database error. |
Get the name of the schedule for the given member’s identity name.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Returns: | The name of the schedule. |
Return type: | str |
Raises GroupManagerDb.Error: | |
If there’s no member with the given identity name in the database, or other database error. |
Get a schedule with the given name.
Parameters: | name (str) – The name of the schedule. |
---|---|
Returns: | A new Schedule object. |
Return type: | Schedule |
Raises GroupManagerDb.Error: | |
If the schedule does not exist or other database error. |
For each member using the given schedule, get the name and public key DER of the member’s key.
Parameters: | name (str) – The name of the schedule. |
---|---|
Returns: | a new dictionary where the dictionary’s key is the Name of the public key and the value is the Blob of the public key DER. Note that the member’s identity name is keyName.getPrefix(-1). If the schedule name is not found, the dictionary is empty. |
Return type: | dictionary<Name, Blob> |
Raises GroupManagerDb.Error: | |
For a database error. |
Check if there is a member with the given identity name.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Returns: | True if there is a member. |
Return type: | bool |
Raises GroupManagerDb.Error: | |
For a database error. |
Check if there is a schedule with the given name.
Parameters: | name (str) – The name of the schedule. |
---|---|
Returns: | True if there is a schedule. |
Return type: | bool |
Raises GroupManagerDb.Error: | |
For a database error. |
List all the members.
Returns: | A new List of Name with the names of all members. |
---|---|
Return type: | Array<Name> |
Raises GroupManagerDb.Error: | |
For a database error. |
List all the names of the schedules.
Returns: | A new List of String with the names of all schedules. |
---|---|
Return type: | Array<str> |
Raises GroupManagerDb.Error: | |
For a database error. |
Rename a schedule with oldName to newName.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If a schedule with newName already exists, if the schedule with oldName does not exist, if newName is empty, or other database error. |
Change the name of the schedule for the given member’s identity name.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If there’s no member with the given identity name in the database, or there’s no schedule named scheduleName, or other database error. |
Update the schedule with name and replace the old object with the given schedule. Otherwise, if no schedule with name exists, a new schedule with name and the given schedule will be added to database.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If the name is empty, or other database error. |
This module defines the Interval class which defines a time duration which contains a start timestamp and an end timestamp. Note: This class is an experimental feature. The API may change.
Bases: object
Create an Interval with one of these forms: Interval(isValid). Interval(startTime, endTime). Interval(interval).
Parameters: |
|
---|
Check if the time point is in this interval.
Parameters: | timePoint (float) – The time point to check as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | True if timePoint is in this interval. |
Return type: | bool |
Raises RuntimeError: | |
if this Interval is invalid. |
Get the end time.
Returns: | The end time as milliseconds since Jan 1, 1970 UTC. |
---|---|
Return type: | float |
Raises RuntimeError: | |
if this Interval is invalid. |
Get the start time.
Returns: | The start time as milliseconds since Jan 1, 1970 UTC. |
---|---|
Return type: | float |
Raises RuntimeError: | |
if this Interval is invalid. |
Set this Interval to the intersection of this and the other interval. This and the other interval should be valid but either can be empty.
Parameters: | interval (Interval) – The other Interval to intersect with. |
---|---|
Returns: | This Interval. |
Return type: | Interval |
Raises RuntimeError: | |
if this Interval or the other interval is invalid. |
Check if this Interval is empty.
Returns: | True if this Interval is empty (start time equals end time), False if not. |
---|---|
Return type: | bool |
Raises RuntimeError: | |
if this Interval is invalid. |
Check if this Interval is valid.
Returns: | True if this interval is valid, False if invalid. |
---|---|
Return type: | bool |
Set this interval to have the same values as the other interval.
Parameters: | other (Interval) – The other Interval with values to copy. |
---|
Set this Interval to the union of this and the other interval. This and the other interval should be valid but either can be empty. This and the other interval should have an intersection. (Contiguous intervals are not allowed.)
Parameters: | interval (Interval) – The other Interval to union with. |
---|---|
Returns: | This Interval. |
Return type: | Interval |
Raises RuntimeError: | |
if this Interval or the other interval is invalid, or if the two intervals do not have an intersection. |
This module defines the Producer class which 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.
Bases: object
Create a Producer to use the given ProducerDb, Face and other values.
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: |
|
---|
Bases: object
Create a new ExcludeEntry.
Parameters: |
|
---|
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: |
|
---|---|
Returns: | The content key name. |
Return type: | Name |
The default onError callback which does nothing.
Exclude all components in the range beginning at “fromComponent”.
Parameters: |
|
---|
Exclude all components in the range ending at “to”.
Parameters: |
|
---|
Exclude all components in the range beginning at “fromComponent” and ending at “to”.
Parameters: |
|
---|
Get the latest entry in the array whose component is less than or equal to component.
Parameters: |
|
---|---|
Returns: | The index of the found entry, or -1 if not found. |
Return type: | int |
Create a list of ExcludeEntry from the Exclude object.
Parameters: | exclude (Exclude) – The Exclude object to read. |
---|---|
Returns: | A new array of ExcludeEntry. |
Return type: | Array<ExcludeEntry> |
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: |
|
---|
This module defines the ProducerDb class which is an abstract base class the storage of keys for the producer. It contains one table that maps time slots (to the nearest hour) to the content key created for that time slot. A subclass must implement the methods. For example, see Sqlite3ProducerDb. Note: This class is an experimental feature. The API may change.
Bases: object
Add key as the content key for the hour covering timeSlot.
Parameters: |
|
---|---|
Raises ProducerDb.Error: | |
If a key for the same hour already exists in the database, or other database error. |
Parameters: | timeSlot (float) – The time slot as milliseconds since Jan 1, 1970 UTC. |
---|---|
Raises ProducerDb.Error: | |
For a database error. |
Get the content key for the hour covering timeSlot.
Parameters: | timeSlot (float) – The time slot as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | A Blob with the encoded key. |
Return type: | Blob |
Raises ProducerDb.Error: | |
If there is no key covering timeSlot or other database error. |
Get the hour-based time slot.
Parameters: | timeSlot (float) – The time slot as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | The hour-based time slot as hours since Jan 1, 1970 UTC. |
Return type: | int |
Check if a content key exists for the hour covering timeSlot.
Parameters: | timeSlot (float) – The time slot as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | True if there is a content key for timeSlot. |
Return type: | bool |
Raises ProducerDb.Error: | |
For a database error. |
This module defines the RepetitiveInterval class which is an advanced interval which can repeat and can be used to find a simple Interval that a time point falls in. Note: This class is an experimental feature. The API may change.
Bases: object
Create a RepetitiveInterval with one of these forms: RepetitiveInterval() A RepetitiveInterval with one day duration, non-repeating.. RepetitiveInterval(startDate, endDate, intervalStartHour, intervalEndHour, nRepeats, repeatUnit). RepetitiveInterval(repetitiveInterval).
Parameters: |
|
---|
Compare this to the other RepetitiveInterval.
Parameters: | other (RepetitiveInterval) – The other RepetitiveInterval to compare to. |
---|---|
Returns: | -1 if this is less than the other, 1 if greater and 0 if equal. |
Return type: | int |
Get the end date.
Returns: | The end date as milliseconds since Jan 1, 1970 UTC. |
---|---|
Return type: | float |
Get an interval that covers the time point. If there is no interval covering the time point, this returns False for isPositive and returns a negative interval.
Parameters: | timePoint (float) – The time point as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | An object with fields “isPositive” and “interval” where isPositive is True if the returned interval is positive or False if negative, and interval is the Interval covering the time point or a negative interval if not found. |
Return type: | RepetitiveInterval.Result |
Get the interval end hour.
Returns: | The interval end hour. |
---|---|
Return type: | int |
Get the interval start hour.
Returns: | The interval start hour. |
---|---|
Return type: | int |
Get the number of repeats.
Returns: | The number of repeats. |
---|---|
Return type: | int |
This module defines the Schedule class which is used to manage the times when a member can access data using two sets of RepetitiveInterval as follows. whiteIntervalList is an ordered set for the times a member is allowed to access to data, and blackIntervalList is for the times a member is not allowed. Note: This class is an experimental feature. The API may change.
Bases: object
Create a Schedule with one of these forms: Schedule() A Schedule with empty whiteIntervalList and blackIntervalList. Schedule(schedule). A copy of the given schedule.
Add the repetitiveInterval to the blackIntervalList.
Parameters: | repetitiveInterval (RepetitiveInterval) – The RepetitiveInterval to add. If the list already contains the same RepetitiveInterval, this does nothing. |
---|---|
Returns: | This Schedule so you can chain calls to add. |
Return type: | Schedule |
Add the repetitiveInterval to the whiteIntervalList.
Parameters: | repetitiveInterval (RepetitiveInterval) – The RepetitiveInterval to add. If the list already contains the same RepetitiveInterval, this does nothing. |
---|---|
Returns: | This Schedule so you can chain calls to add. |
Return type: | Schedule |
Convert an ISO time representation with the “T” in the middle to a UNIX timestamp.
Parameters: | timeString (str) – The ISO time representation. |
---|---|
Returns: | The timestamp as milliseconds since Jan 1, 1970 UTC. |
Return type: | float |
Get the interval that covers the time stamp. This iterates over the two repetitive interval sets and find the shortest interval that allows a group member to access the data. If there is no interval covering the time stamp, this returns False for isPositive and a negative interval.
Parameters: | timeStamp (float) – The time stamp as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | An object with fields “isPositive” and “interval” where isPositive is True if the returned interval is positive or False if negative, and interval is the Interval covering the time stamp, or a negative interval if not found. |
Return type: | Schedule.Result |
Convert a UNIX timestamp to ISO time representation with the “T” in the middle.
Parameters: | msSince1970 (float) – Timestamp as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | The string representation. |
Return type: | str |
This module defines the Sqlite3ConsumerDb class which extends ConsumerDb to implement the storage of decryption keys for the consumer using SQLite3. Note: This class is an experimental feature. The API may change.
Bases: pyndn.encrypt.consumer_db.ConsumerDb
Create an Sqlite3ConsumerDb to use the given SQLite3 file.
Parameters: | databaseFilePath (str) – The path of the SQLite file. |
---|
Add the key with keyName and keyBlob to the database.
Parameters: |
|
---|---|
Raises ConsumerDb.Error: | |
If a key with the same keyName already exists in the database, or other database error. |
This module defines the Sqlite3GroupManagerDb class which extends GroupManagerDb to implement the storage of data used by the GroupManager using SQLite. Note: This class is an experimental feature. The API may change.
Bases: pyndn.encrypt.group_manager_db.GroupManagerDb
Create an Sqlite3GroupManagerDb to use the given SQLite3 file.
Parameters: | databaseFilePath (str) – The path of the SQLite file. |
---|
Add a new member with the given key named keyName into a schedule named scheduleName. The member’s identity name is keyName.getPrefix(-1).
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If there’s no schedule named scheduleName, if the member’s identity name already exists, or other database error. |
Add a schedule with the given name.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If a schedule with the same name already exists, if the name is empty, or other database error. |
Delete a member with the given identity name. If there is no member with the identity name, then do nothing.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Raises GroupManagerDb.Error: | |
For a database error. |
Delete the schedule with the given name. Also delete members which use this schedule. If there is no schedule with the name, then do nothing.
Parameters: | name (str) – The name of the schedule. |
---|---|
Raises GroupManagerDb.Error: | |
For a database error. |
Get the name of the schedule for the given member’s identity name.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Returns: | The name of the schedule. |
Return type: | str |
Raises GroupManagerDb.Error: | |
If there’s no member with the given identity name in the database, or other database error. |
Get a schedule with the given name.
Parameters: | name (str) – The name of the schedule. |
---|---|
Returns: | A new Schedule object. |
Return type: | Schedule |
Raises GroupManagerDb.Error: | |
If the schedule does not exist or other database error. |
For each member using the given schedule, get the name and public key DER of the member’s key.
Parameters: | name (str) – The name of the schedule. |
---|---|
Returns: | a new dictionary where the dictionary’s key is the Name of the public key and the value is the Blob of the public key DER. Note that the member’s identity name is keyName.getPrefix(-1). If the schedule name is not found, the dictionary is empty. |
Return type: | dictionary<Name, Blob> |
Raises GroupManagerDb.Error: | |
For a database error. |
Check if there is a member with the given identity name.
Parameters: | identity (Name) – The member’s identity name. |
---|---|
Returns: | True if there is a member. |
Return type: | bool |
Raises GroupManagerDb.Error: | |
For a database error. |
Check if there is a schedule with the given name.
Parameters: | name (str) – The name of the schedule. |
---|---|
Returns: | True if there is a schedule. |
Return type: | bool |
Raises GroupManagerDb.Error: | |
For a database error. |
List all the members.
Returns: | A new List of Name with the names of all members. |
---|---|
Return type: | Array<Name> |
Raises GroupManagerDb.Error: | |
For a database error. |
List all the names of the schedules.
Returns: | A new List of String with the names of all schedules. |
---|---|
Return type: | Array<str> |
Raises GroupManagerDb.Error: | |
For a database error. |
Rename a schedule with oldName to newName.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If a schedule with newName already exists, if the schedule with oldName does not exist, if newName is empty, or other database error. |
Change the name of the schedule for the given member’s identity name.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If there’s no member with the given identity name in the database, or there’s no schedule named scheduleName, or other database error. |
Update the schedule with name and replace the old object with the given schedule. Otherwise, if no schedule with name exists, a new schedule with name and the given schedule will be added to database.
Parameters: |
|
---|---|
Raises GroupManagerDb.Error: | |
If the name is empty, or other database error. |
This module defines the Sqlite3ProducerDb class which extends ProducerDb to implement storage of keys for the producer using SQLite3. It contains one table that maps time slots (to the nearest hour) to the content key created for that time slot. Note: This class is an experimental feature. The API may change.
Bases: pyndn.encrypt.producer_db.ProducerDb
Create an Sqlite3ProducerDb to use the given SQLite3 file.
Parameters: | databaseFilePath (str) – The path of the SQLite file. |
---|
Add key as the content key for the hour covering timeSlot.
Parameters: |
|
---|---|
Raises ProducerDb.Error: | |
If a key for the same hour already exists in the database, or other database error. |
Parameters: | timeSlot (float) – The time slot as milliseconds since Jan 1, 1970 UTC. |
---|---|
Raises ProducerDb.Error: | |
For a database error. |
Get the content key for the hour covering timeSlot.
Parameters: | timeSlot (float) – The time slot as milliseconds since Jan 1, 1970 UTC. |
---|---|
Returns: | A Blob with the encoded key. |
Return type: | Blob |
Raises ProducerDb.Error: | |
If there is no key covering timeSlot or other database error. |