Concatenation Mapping Procedure

This section describes how to map a Concatenation. It only applies as invoked by another mapping procedure.

A Concatenation is a truncated Concatenation if it is enclosed in curly braces and followed by the truncation operator (e.g { <a> <b> }//).

  1. Nested concatenations are eliminated according to the following rule. If concat-outer is an unlabeled, non-truncated concatenation and concat-inner is one of the operands of concat-outer and is also an unlabeled, non-truncated concatenation, then concat-inner is replaced in concat-outer by its operands. The requirement that concat-inner be unlabeled is so that all possible semantic information is carried over into the ASN.1. The requirement that concat-outer be unlabeled is probably not really necessary and could be taken up for futher study.

  2. For each operand that is an Intersection, do the following. Repeat these steps until any Intersections that remain require no additional action.

    1. Invoke the Intersection Analysis procedure on the Intersection.

    2. If the Intersection has a length determinant, do the following.

      1. Verify that the Intersection is the final operand in the Concatenation. This limitiation is motivated by the internal working of our code generator relative to length-constrained content.

      2. If the Intersection's constrained-operand is a Concatenation, replace the Intersection with the operands of that Concatenation. Otherwise, replace the Intersection with the constrained-operand.

    3. Otherwise (the Intersection does not have a length determinant), no additional action is required.

  3. Do the following for each of the operands of the Concatenation, in order. The purpose of this step is to determine the ASN.1 type or ASN.1 component that each operand maps to, or whether the operand instead represents either padding or a literal bit string. If an operand does not do any of these, it is an error. (Note: if the Alternation mapping is invoked and the particular-general case applies, the operand will actually be mapped to two ASN.1 components, rather than just one.)

    1. If the operand has an exponent, determine whether the repetition is delimited using a more-bit and done-bit. This is the case if the following apply:

      • The operand's exponent is infinite.

      • The exponent's base string has a determinant, call it more-bit, consisting of a single bit.

      • The operand is immediately followed by a literal string consisting of a single bit, call it done-bit. The negation of done-bit is more-bit.

      In this case, do the following:

      1. Discard the operand following this operand.

      2. Invoke the Exponential mapping procedure on this operand.

      3. If the Exponential mapping does not produce a type and the exponent's base has an empty remainder, we recognize a case of an INTEGER with "count-bits" encoding. The operand maps to the ASN.1 type: INTEGER (0..255). The encoding is as follows. For a value v, there are v bits equal to the more-bit, followed by a single done-bit.

      4. Otherwise, the Exponential mapping shall have produced an ASN.1 type T, which is a SEQUENCE OF R, for some type R. The operand maps to T. The encoding of T shall be formed as follows (this alters the encoding specified by the Exponential mapping). For each R in T, encode a more-bit followed by the encoding for R. Finally, end the encoding by encoding a done-bit. If the Exponential mapping procedure did not produce an ASN.1 type, it is an error.

    2. If the operand has an exponent and the repetition is not delimited using a more-bit and done-bit, do the following.

      1. Invoke the Exponential mapping procedure on the operand.

      2. If the exponent is infinite, then one of the following cases must apply, or else it is an error.

        1. The Exponential mapping produced an ASN.1 type and no operands follow this operand. This is a case of container-delimited repetition. (The requirement that there be no subsequent operand is due to the fact that nothing can be encoded following a container-delimited repetition.)

        2. The Exponential mapping recognized the operand as padding.

      3. As long as the previous clause does not indicate an error, this operand is mapped to the result of invoking the Exponential mapping.

    3. Otherwise, invoke the CSN1String mapping procedure on the operand.

    4. If the CSN1String mapping procedure recognized a single pad bit, then the operand is mapped to the ASN.1 type INTEGER(0..1). When the ASN.1 component is created for this operand, it shall have a DEFAULT value corresponding to the value of the pad bit.

    5. It is an error if any operand except for the last is mapped to padding. This is because padding is a repetition whose length is determined by the container boundary (thus, nothing is permitted to follow it).

  4. Let asn1objects be the set of ASN.1 types and ASN.1 components that the operands were mapped to.

  5. If asn1objects has more than one member OR if any of the members is an OPTIONAL ASN.1 component, OR if there is only a single member and that member is an ASN.1 component and the last operand is mapped to padding then do the following.

    1. Construct a SEQUENCE type as follows. This will be the type produced by this Concatenation procedure.

    2. Add a NamedType to the SEQUENCE for each of the operands that mapped to an ASN.1 type or ASN.1 component, in order. If any of the operands mapped were mapped to two components, add them both just as if they were produced by two operands.

    3. The identifier for the NamedType shall be determined according to the rules in "ASN.1 Identifier Assignment". If the operand was mapped to an ASN.1 type, that shall be the type for the NamedType. Otherwise, the operand was mapped to a component with an ASN.1 type, which shall be used.

    4. If the ASN.1 item is a component and the procedure that created the ASN.1 component specified it should be optional, then it shall be optional. That procedure shall have specified how the presence or absence is represented in the encoding. If that procedure specified that a DEFAULT value shall be specified, then it shall be specified.

    5. If the Concatenation is truncated, all of the components added to the SEQUENCE shall be OPTIONAL, with the optionality determined by the container. A decoder shall recognize the component as present as long as there are more bits in the encoding at the point where the component would appear. If the component was already OPTIONAL, its presence may have been determined by a presence flag. In that case, it is additionally determined by container as well. (In such a case, the boundary of the container is used to determine whether the combination of the presence bit and the value are present, and if present, then the presence bit determines whether the value is present or not.)

    6. Additionally, if the Concatenation is truncated, each operand shall either be padding or else be mapped to an ASN.1 type or ASN.1 component. This requirement is so that the optionality of everything in the Concatenation, implied by the truncation, can be modeled in the ASN.1.

    7. The encoding of the SEQUENCE shall consist of the encoding of its component types, in order.

    8. If a length determinant was identified in the Concatenation (see the section on Intersection Procedures), then let encoded-value be the encoded value for the corresponding component. Let length-value be the result of evaluating the constraining-operand's exponent at encoded-value. Then length-value shall be the length of the encoding for the components following the length determinant in the SEQUENCE, including any padding bits. The units for the length shall be bits or octets, depending on the constraining-operand's use of a reference to bit or octet.

    9. If the Concatenation ended with padding, the interpretation depends on whether there was a length determinant or not. If there was a length determinant with units in octets, the encoder shall pad using the pad bit so that the length of the length-constrained content is a multiple of 8 bits. If the units were bits, the encoder need not do any padding. In both cases, a decoder must be prepared to skip any padding bits. If there is no length determinant, we assume the encoding of the SEQUENCE should be padded to a mulitple of 8 bits.

  6. Otherwise, if asn1objects has a single member, the Concatenation is mapped to that same item, whether it is an ASN.1 type or ASN.1 component.