Hi,
    I am not quite sure if I understood the problem but here is my
explanation. When AUTOMATIC Tagging is used the type specified in the
SEQUENCE OF is not tagged (i.e. it does not become something like the 1st
element of the SEQUENCE OF has tag 1, second 2 and so on). This seem to be
the basis for the Encoded Data 2 (where the 1st element of the sequence of
says [0] and second [1].
    In our case for each element of SEQUENCE OF B the tag used is that of B
(in this case corresponding to that of a SEQUENCE - 30). As such all
elements withing the value field of SEQUENCE OF B, will have tag 30. If the
definition of B were

B ::= [0] SEQUENCE {
     c     [0] INTEGER,
     d     [1] OCTET STRING
}

then the encoded data would have been

30 1B                                                  /* A ::= SEQUENCE */
         80 01 01                                                  /* a
INTEGER */
         A1 16                                                      /* b
SEQUENCE OF B*/
                   A0 09                               /* B ::= SEQUENCE */
                            80 01 01                               /* c
INTEGER */
                            81 04 01 02 03 04                  /* d OCTET
STRING */
                   A0 09                               /* B ::= SEQUENCE */
                            80 01 01                               /* c
INTEGER */
                            81 04 01 02 03 04                  /* d OCTET
STRING */

    An easy way to remember this is that AUTOMATIC tagging affects only the
representation itself (i.e. an ASN.1 spec can be generated with the tags).
ASN.1 does not allow specifying tag for each member of a SEQUENCE OF or SET
OF. So AUTOMATIC tagging does not affect the same. Hope this explains
things.

Regd
SamY
(Ramaswamy)

-----Original Message-----
From: Raymond Javier [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 29, 2004 1:21 PM
To: [EMAIL PROTECTED]
Subject: [ASN.1] Tag of SEQUENCE OF if AUTOMATIC Tagging


Hi,

I am confused on Tagging when SEQUENCE OF is used

I have the following ASN.1 BER definition:

MY_PROJ DEFINITIONS AUTOMATIC TAGS ::=

BEGIN

A ::= SEQUENCE {
     a     [0] INTEGER,
     b     [1] SEQUENCE OF B
}

B ::= SEQUENCE {
     c     [0] INTEGER,
     d     [1] OCTET STRING
}

END

Encoded Data 1.
30 1B                                                  /* A ::= SEQUENCE */
         80 01 01                                                  /* a
INTEGER */
         A1 16                                                      /* b
SEQUENCE OF B*/
                   30 09                               /* B ::= SEQUENCE */
                            80 01 01                               /* c
INTEGER */
                            81 04 01 02 03 04                  /* d OCTET
STRING */
                   30 09                               /* B ::= SEQUENCE */
                            80 01 01                               /* c
INTEGER */
                            81 04 01 02 03 04                  /* d OCTET
STRING */


Encoded Data 2.
30 1B                                                  /* A ::= SEQUENCE */
         80 01 01                                                  /* a
INTEGER */
         A1 16                                                      /* b
SEQUENCE OF B*/
                   A0 09                               /* B ::= SEQUENCE */
                            80 01 01                               /* c
INTEGER */
                            81 04 01 02 03 04                  /* d OCTET
STRING */
                   A1 09                               /* B ::= SEQUENCE */
                            80 01 01                               /* c
INTEGER */
                            81 04 01 02 03 04                  /* d OCTET
STRING */


Which encoded data is correct?

Reply via email to