Hi Piotr,
> I found an example too :
> Person ::= SEQUENCE {
> title [0] IMPLICIT IA5String OPTIONAL,
> name IA5String }
>
> form1 is :
>
> form1 Person ::= {
> title "Sir",
> name "Peter",
> }
>
> I agree that it should be coded in the following
> way :
>
> 0x30 0x0c
> (***) 0x80 0x03 0x053 0x69 0x72
> 0x16 0x05 0x50 0x65 0x74 0x65 0x72
>
> But I don't understand how decoder should now
> what ANS.1 type is mentioned in (***) ?
> It is not possible to guess IA5String tag type
> from 0x80 0x03 0x053 0x69 0x72 binaries ....
>
> 0x80 ---> class: context-specific
> method: primitive
> tag type number: 0 (???)
>
> Could you please someone explain it to me, how decoder
> can recognize appropriate tag type ?
> I will appreciate any kind of help !
>
The decoder knows that the [0] tag defined in the syntax is defined for a type that is
an IA5String because it should have saved
this information somewhere after the compilation of the ASN1 module and this
informaiton should be available at runtime.
For information on tagging issues, there is a must tutorial from John Larmouth at
http://www.larmouth.demon.co.uk/tutorials/tagging.ppt.
And I have attached an interesting email from Conrad Sigona as a reply to a tagging
question.
I hope this will help you.
Bruno
>
> Thanks in advance for your help !
>
> Best regards,
> Piotr
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Small Business $15K Web Design Giveaway
> http://promotions.yahoo.com/design_giveaway/
--- Begin Message ---
>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
--- End Message ---