A Python class is generated for an ASN.1 OCTET STRING type only if the following are true:
The type is tagged.
The type has a size constraint (for example, OCTET STRING (SIZE(1..5))
If a class is generated, it will contain static methods for the BER encoding or decoding of the value.
Example ASN.1:
Os2 ::= OCTET STRING (SIZE(1..5))
Generated Python Class:
class Os2: @staticmethod def ber_decode(decbuf, explicit=True, impllen=None): ... @staticmethod def ber_encode(value, encbuf, explicit=True): ...
The value that is returned by the decode method or passed into the encode method is a Python bytearray. Also, for encode, the type of the value passed in may be a string. In this case, the ordinal bytes of the characters are encoded.
See the BER encode/decode methods for information on how to call these methods.