OpenType

class pyasn1.type.opentype.OpenType(name, typeMap=None)

Create ASN.1 type map indexed by a value

The OpenType object models an untyped field of a constructed ASN.1 type. In ASN.1 syntax it is usually represented by the ANY DEFINED BY for scalars or SET OF ANY DEFINED BY, SEQUENCE OF ANY DEFINED BY for container types clauses. Typically used together with Any object.

OpenType objects duck-type a read-only Python dict objects, however the passed typeMap is not copied, but stored by reference. That means the user can manipulate typeMap at run time having this reflected on OpenType object behavior.

The OpenType class models an untyped field of a constructed ASN.1 type. In ASN.1 syntax it is usually represented by the ANY DEFINED BY for scalars or SET OF ANY DEFINED BY, SEQUENCE OF ANY DEFINED BY for container types clauses. Typically used with Any type.

Parameters
  • name (str) – Field name

  • typeMap (dict) – A map of value->ASN.1 type. It’s stored by reference and can be mutated later to register new mappings.

Examples

For untyped scalars:

openType = OpenType(
    'id', {1: Integer(),
           2: OctetString()}
)
Sequence(
    componentType=NamedTypes(
        NamedType('id', Integer()),
        NamedType('blob', Any(), openType=openType)
    )
)

For untyped SET OF or SEQUENCE OF vectors:

openType = OpenType(
    'id', {1: Integer(),
           2: OctetString()}
)
Sequence(
    componentType=NamedTypes(
        NamedType('id', Integer()),
        NamedType('blob', SetOf(componentType=Any()),
                  openType=openType)
    )
)

More information on open type use can be found here.