Run-time and Generated Python Decode Methods

Three types of Python decode functions/methods are available for decoding different types of data. These are:

The signature for a Standard base run-time method in the Asn1BerDecodeBuffer is as follows:

def decode_* (self, explicit=True, impllen=None)

where * would be a primitive type name (boolean, integer, etc.).

The self argument is a reference to the Asn1BerDecodeBuffer object from which it was invoked (note that in Python, this argument is not explicitly passed, it refers to the object invoking the method). The explicit argument is a boolean argument indicating if the universal tag and length associated with the primitive type should be parsed prior to decoding the content.

The impllen argument is a length oject that only has meaning if explicit is False. In this case, it specified the length of the contents field to be decoded. If explicit is True, this length is parsed from the encoded tag/length value that precedes the content.

The return value is the decoded content value. This will be of whatever type the content being decoded is as specified in the ASN.1 schema. Decoding errors are handled by the Python exception mechanism.

The signature for a static BER decode method in a class generated for a primitive type is as follows:

    @staticmethod
    def ber_decode(decbuf, explicit=True, impllen=None):

In this case, there is no 'self' argument. A reference to the decode buffer object is passed as a formal argument in the 2nd position. The explicit and impllen arguments are as they were in standard base run-time method case and the return value is also the same (the decoded value).

The signature for an instance BER decode method in a class generated for a constructed type is as follows:

    def ber_decode(self, decbuf, explicit=True, impllen=None)

The self argument is a reference to an object of the generated class (note that in Python, this argument is not explicitly passed, it refers to the object invoking the method). >The decbuf argument is a reference to BER decode buffer object to be used to encode the data. The explicit and impllen arguments are that same as in the other two cases.