Fields of constructed types

The Sequence, Set and Choice ASN.1 types embed other ASN.1 types as named fields.

Each field can be expressed via the NamedType object while the individual fields are brought together by the NamedTypes object.

Ultimately, the fields get attached to the ASN.1 type’s .componentType attributes.

class RSAPublicKey(Sequence):
    """
    ASN.1 specification:

    RSAPublicKey ::= SEQUENCE {
        modulus           INTEGER,  -- n
        publicExponent    INTEGER   -- e
    }
    """
    componentType = NamedTypes(
        NamedType('modulus', Integer()),
        NamedType('publicExponent', Integer())
    )