pyndn.encoding.der package

Submodules

pyndn.encoding.der.der module

This module defines the Der object with known DER node types.

class pyndn.encoding.der.der.Der[source]

Bases: object

BitString = 3
BmpString = 30
Boolean = 1
CharacterString = 29
EmbeddedPdv = 43
Enumerated = 10
Eoc = 0
External = 40
GeneralString = 27
GeneralizedTime = 24
GraphicString = 25
Ia5String = 22
Integer = 2
Null = 5
NumericString = 18
ObjectDescriptor = 7
ObjectIdentifier = 6
OctetString = 4
PrintableString = 19
Real = 9
RelativeOid = 13
Sequence = 48
Set = 49
T61String = 20
UniversalString = 28
UtcTime = 23
Utf8String = 12
VideoTexString = 21
VisibleString = 26

pyndn.encoding.der.der_exceptions module

Exceptions that may occur during DER encoding/decoding Correspond to exceptions in ndn-cpp

exception pyndn.encoding.der.der_exceptions.DerDecodingException(message)[source]

Bases: pyndn.encoding.der.der_exceptions.DerException

exception pyndn.encoding.der.der_exceptions.DerEncodingException(message)[source]

Bases: pyndn.encoding.der.der_exceptions.DerException

exception pyndn.encoding.der.der_exceptions.DerException[source]

Bases: exceptions.Exception

exception pyndn.encoding.der.der_exceptions.NegativeLengthException(message)[source]

Bases: pyndn.encoding.der.der_exceptions.DerException

pyndn.encoding.der.der_node module

class pyndn.encoding.der.der_node.DerBitString(inputBuf=None, padding=None)[source]

Bases: pyndn.encoding.der.der_node.DerNode

class pyndn.encoding.der.der_node.DerBoolean(val=None)[source]

Bases: pyndn.encoding.der.der_node.DerNode

toVal()[source]
class pyndn.encoding.der.der_node.DerByteString(inputData, nodeType)[source]

Bases: pyndn.encoding.der.der_node.DerNode

toVal()[source]

For byte string types, the payload encodes the string directly, so it is used as a representation. :return: The encoded string :rtype: bytearray

class pyndn.encoding.der.der_node.DerGeneralizedTime(msSince1970=None)[source]

Bases: pyndn.encoding.der.der_node.DerNode

static toDerTimeString(msSince1970)[source]

Convert a UNIX timestamp to the internal string representation :param msSince1970: Timestamp as milliseconds since Jan 1, 1970 :type msSince1970: float :return: The time string :rtype: str

toVal()[source]
Returns:The timestamp encoded in this node as milliseconds since 1970
Return type:float
class pyndn.encoding.der.der_node.DerInteger(integer=None)[source]

Bases: pyndn.encoding.der.der_node.DerNode

toVal()[source]
class pyndn.encoding.der.der_node.DerNode(nodeType)[source]

Bases: object

decode(inputBuf, startIdx=0)[source]

Decode and store the data from an input buffer. :param inputBuf: The input buffer to read from. :type inputBuf: bytearray or Blob :param startIdx: (optional) An offset into the buffer. :type startIdx: int

encode()[source]
Returns:The raw data encoding for this node
Return type:Blob
getChildren()[source]

If this object is a DerSequence, get the children of this node. Otherwise, raise an exception. (DerSequence overrides to implement this method.) :return: The children of this node :rtype: array of DerNode :raises: DerDecodingException if this object is not a DerSequence.

getPayload()[source]

Get a copy of the payload bytes. :return: A copy of the payload. :rtype: Blob

static getSequence(children, index)[source]

Check that index is in bounds for the children list, and return children[index].

Parameters:
  • children (array of DerNode) – The list of DerNode, usually returned by another call to getChildren.
  • index (int) – The index of the children.
Returns:

children[index] which is a DerSequence

Return type:

DerSequence

Raises :

DerDecodingException if index is out of bounds or if children[index] is not a DerSequence.

getSize()[source]

Get the total length of the encoding. :return: The total (header + payload) length :rtype: int

static parse(inputBuf, startIdx=0)[source]

Parse the data from the input buffer recursively and return the root as a subclass of DerNode. :param inputBuf: The input buffer to read from. :type inputBuf: bytearray or Blob :param startIdx: (optional) An offset into the buffer. :type startIdx: int

toVal()[source]

Convert the encoded data to a standard representation. Overridden by some subclasses (e.g. DerBoolean) :return: The encoded data :rtype: Blob

class pyndn.encoding.der.der_node.DerNull[source]

Bases: pyndn.encoding.der.der_node.DerNode

class pyndn.encoding.der.der_node.DerOctetString(inputData=None)[source]

Bases: pyndn.encoding.der.der_node.DerByteString

class pyndn.encoding.der.der_node.DerOid(oid=None)[source]

Bases: pyndn.encoding.der.der_node.DerNode

prepareEncoding(value)[source]

Encode a sequence of integers into an OID object.

toVal()[source]
Returns:The string representation of the OID
Return type:string
class pyndn.encoding.der.der_node.DerPrintableString(inputData=None)[source]

Bases: pyndn.encoding.der.der_node.DerByteString

toVal()[source]
Returns:The string encoded in the node
Return type:string
class pyndn.encoding.der.der_node.DerSequence[source]

Bases: pyndn.encoding.der.der_node.DerStructure

class pyndn.encoding.der.der_node.DerStructure(nodeType)[source]

Bases: pyndn.encoding.der.der_node.DerNode

addChild(node, notifyParent=False)[source]

Add a child to this node. :param node: The child node to add. :type node: DerNode :param notifyParent: (optional) Set to true to cause any containing nodes to update their size :type notifyParent: boolean

decode(inputBuf, startIdx=0)[source]

Decode and store the data from an input buffer. Recursively populates child nodes. :param inputBuf: The input buffer to read from. :type inputBuf: bytearray or Blob :param startIdx: (optional) An offset into the buffer. :type startIdx: int

encode()[source]
Returns:The raw data encoding for this node and its children
Return type:Blob
getChildren()[source]
Returns:The children of this node
Return type:array of DerNode
getSize()[source]

Get the total length of the encoding, including children :return: The total (header + payload) length :rtype: int

setChildChanged()[source]

Mark the child list as dirty, so that we update size when necessary.

updateSize()[source]

Returns a Blob

Module contents