Package Crypto :: Package Util :: Module asn1 :: Class DerObject
[frames] | no frames]

Class DerObject

object --+
         |
        DerObject
Known Subclasses:

Base class for defining a single DER object.

This class should never be directly instantiated.

Instance Methods
 
__init__(self, asn1Id=None, payload='', implicit=None, constructed=False)
Initialize the DER object according to a specific ASN.1 type.
 
encode(self)
Return this DER element, fully encoded as a binary byte string.
 
decode(self, derEle)
Decode a complete DER element, and re-initializes this object with it.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, asn1Id=None, payload='', implicit=None, constructed=False)
(Constructor)

 
Initialize the DER object according to a specific ASN.1 type.
Parameters:
  • asn1Id (integer) - The universal DER tag identifier for this object (e.g. 0x10 for a SEQUENCE). If None, the tag is not known yet.
  • payload (byte string) - The initial payload of the object. If not specified, the payload is empty.
  • implicit (integer) - The IMPLICIT tag to use for the encoded object. It overrides the universal tag asn1Id.
  • constructed (bool) - True when the ASN.1 type is constructed. False when it is primitive.
Overrides: object.__init__

decode(self, derEle)

 
Decode a complete DER element, and re-initializes this object with it.
Parameters:
  • derEle (byte string) - A complete DER element.
Raises:
  • ValueError - In case of parsing errors.
  • EOFError - If the DER element is too short.