derberasn.1

How do you encode a post-1994 ASN.1 EXTERNAL type?


Background:

Prior to 1994, EXTERNAL was defined like so (with automatic and explicit tagging):

EXTERNAL  ::=  [UNIVERSAL 8] IMPLICIT SEQUENCE
    {
    direct-reference  OBJECT IDENTIFIER OPTIONAL,
    indirect-reference  INTEGER OPTIONAL,
    data-value-descriptor  ObjectDescriptor  OPTIONAL,
    encoding  CHOICE
                {single-ASN1-type  [0] ANY,
                octet-aligned     [1] IMPLICIT OCTET STRING,
                arbitrary         [2] IMPLICIT BIT STRING}
    }

But since then, it has been defined as:

EXTERNAL := [UNIVERSAL 8] IMPLICIT SEQUENCE {
    identification CHOICE {
        syntax OBJECT IDENTIFIER,
        presentation-context-id INTEGER,
        context-negotiation SEQUENCE {
            presentation-context-id INTEGER,
            transfer-syntax OBJECT IDENTIFIER } },
    data-value-descriptor ObjectDescriptor OPTIONAL,
    data-value OCTET STRING }

Dubuisson's ASN.1 says (page 412):

the context-specific tags, in particular, which appear before the alternatives of the encoding component (of type CHOICE) must be encoded but not those computed in the 1994 version.

On page 413, he describes how to encode an INSTANCE OF, which he notes is encoded identically to an EXTERNAL. The identification shows as being encoded by just a universal tag with a number of 6 (OBJECT IDENTIFIER). The encoding shows as being of the form

[CONTEXT 0]
    [UNIVERSAL 2]

meaning that he is encoding an INTEGER, 5, as his choice of single-ASN-type.

My question

If post-1994 version of EXTERNAL is backwards-compatible, then data-value would have to translate to one of the pre-1994 alternatives for encoding. Which one is it?

In other words, if I encode a post-1994 EXTERNAL (using presentation-context-id as our choice of identification just for the sake of the example), does it get encoded as

[UNIVERSAL 8]
    [UNIVERSAL 2] (presentation-context-id => indirect-reference)
    [CONTEXT 0] (data-value => single-ASN1-type)
        [UNIVERSAL 4]

or

[UNIVERSAL 8]
    [UNIVERSAL 2] (presentation-context-id => indirect-reference)
    [CONTEXT 1] (data-value => octet-aligned)

Thanks in advance!


Solution

  • Please refer to Rec. ITU-T X.690 | ISO/IEC 8825-1 clause 18. It describes in detail how the backward compatibility is maintained, indicating exactly how to map a value for the X.680 EXTERNAL associated sequence to the following SEQUENCE defined in X.690:

    [UNIVERSAL 8] IMPLICIT SEQUENCE {
        direct-reference                OBJECT IDENTIFIER OPTIONAL,
        indirect-reference              INTEGER OPTIONAL,
        data-value-descriptor           ObjectDescriptor OPTIONAL,
        encoding                        CHOICE {
        single-ASN1-type                        [0] ABSTRACT-SYNTAX.&Type,
        octet-aligned                           [1] IMPLICIT OCTET STRING,
        arbitrary                               [2] IMPLICIT BIT STRING } }
    

    Also, this sequence assumes an EXPLICIT TAGS environment rather than AUTOMATIC TAGS as the sequence in X.680.