>given the following definition: > T1 ::= [1] IMPLICIT T2 > T2 ::= [2] IMPLICIT T3 > T3 ::= INTEGER >I do understand that for T1 only one tag [APPL 1] has to be encoded.
When you write APPL, do you mean that the tag is [APPLICATION 1]? That would be incorrect. The default is context-specific, not application. But your real question is when one tag replaces another and when one tag is used in addition to another. The answer is simple and consistent, even consistent to the point of absurdity as you'll see lower on the page. In your example, you have T1 ::= [1] IMPLICIT T2 which is really T1 ::= [1] IMPLICIT [2] IMPLICIT T3 which itself is really T1 ::= [1] IMPLICIT [2] IMPLICIT INTEGER INTEGER has a default universal 2 tag, which I'll write [UNIVERSAL 2] just to be clear (understand, however, that you're not allowed to write universal tags in ASN.1). So, written out in its expanded form, you have T1 ::= [1] IMPLICIT [2] IMPLICIT [UNIVERSAL 2] INTEGER Here's the rule: look at the word IMPLICIT as meaning "instead of" and the word EXPLICIT as meaning "in addition to". Applying the rule, you have T1 ::= [1] instead of [2] instead of [UNIVERSAL 2] INTEGER Reading from the right, we start out with [UNIVERSAL 2], but we see that [2] is used "instead of" [UNIVERSAL 2], so we can dismiss the [UNIVERSAL 2]. Likewise [1] is used "instead of" [2] so we can also dismiss [2], ending up with only [1]. The table below shows the BER encoding of each case t1 T1 ::= 5 A10105 t2 T2 ::= 5 A20105 t3 T3 ::= 5 020105 >But I'm a little bit unsure about: > T1 ::= [1] IMPLICIT T2 > T2 ::= [2] EXPLICIT T3 > T3 ::= INTEGER >From my intuition I would say two tags have to be encoded for T1: >[APPL 1] and [UNIV 2]. Right? The rule says you would interpret T1 as T1 ::= [1] instead of [2] in addition to [UNIVERSAL 2] INTEGER So, although you're wrong for using the word APPL, you're right as far as tag replacement goes. Here are the sample BER encodings. t1 T1 ::= 5 A103020105 t2 T2 ::= 5 A203020105 t3 T3 ::= 5 020105 >Given a more complex definition: > T1 ::= [1] IMPLICIT T2 > T2 ::= [2] EXPLICIT T3 > T3 ::= [3] IMPLICIT T4 > T4 ::= INTEGER >I think the two tags [APPL 1] and [APPL 2] have to be encoded for T1. >Right? >in the 3rd example I wrote: >> I think the two tags [APPL 1] and [APPL 2] have to be encoded for T1. >this should actually read: >I think the two tags [APPL 1] and [APPL 3] have to be encoded for T1. Your corrected version ([1] and [3]) is right (aside from the word APPL, that is). You could even have written T1 ::= [1] [2] [3] [4] INTEGER or T1 ::= [1] IMPLICIT [2] IMPLICIT [3] IMPLICIT [4] IMPLICIT INTEGER or T1 ::= [1] IMPLICIT [2] EXPLICIT [3] IMPLICIT [4] EXPLICIT INTEGER Of course, these examples are silly, but nonetheless syntactically correct, and no matter how silly or complicated, they can be consistently understood using the "instead of" or "in addition to" rule. ===================================================================== Conrad Sigona Toll Free : 1-888-OSS-ASN1 OSS Nokalva Voice Mail : 1-732-302-9669 x400 [EMAIL PROTECTED] Fax : 1-419-831-5035 http://www.oss.com My direct line : 1-315-845-1773