Banibrata Dutta wrote:
Hello Lev:
Does the ASN.1 specification explicitly say that the "closest" [00 00]
should be used to terminate an indefinite TLV ? I search (but not with a
very fine tooth comb) the specs, and didn't find such a thing mentioned.
It does not say "closest", and I did not mean "closest" in this sense
either. I was referring to the "closest" end-of-content octets in your
example only.
The specification says (See X.680: 8.1.3.6.2, 8.1.4, 8.1.5) that the
end-of-content octets should follow the content. However, the content
may consist of multiple TLV tuples, each of them with indefinite length
form.
I did mention a "stack of expectations". This concept is used in the
compiler to manage multiple levels of indefinite length wrappings.
Consider the following:
T1 iL ; Outer type
T2 iL ; Inner type
T3 iL ; And even more...
VVVV ; Value octets for T3
[1] 00 00 ; Terminates T3
[2] 00 00 ; Terminates T2
[3] 00 00 ; Terminates T1
[4] 00 00 ; Irrelevant; garbage or outer "T0" type.
Basically, the T3 encoding is only complete when it includes the
end-of-content octets, as specified in 8.1.3.6. It implies that
the T2 type cannot be terminated by end-of-content at [1], because
end-of-content sequence at [1] "belongs" (8.1.3.6.2) to the T3 type.
Similarly, end-of-content octets at location [2] belongs to
the T2 type (also beacause of 8.1.3.6.2).
(T1 iL (T2 iL (T3 iL VVVV 00 00) 00 00) 00 00)
So, the answer is not that the indefinite length encoding is terminated
by the "closest" end-of-content octets, and not that the type is
terminated by the "farther" end-of-content octets, but that the encoding
is terminated when the algorithm sees the first end-of-content bytes
at the _corresponding_ "TLV tree" level (see [4]).
Thanks for your clarification.
regards,
Banibrata.
-----Original Message-----
From: Lev Walkin [mailto:[EMAIL PROTECTED]
Sent: Sunday, February 27, 2005 9:01 AM
To: Banibrata Dutta
Cc: [email protected]
Subject: Re: [ASN1] question about indefinite encoding in BER
Banibrata Dutta wrote:
Hi,
My question is about indefinite form of encoding in BER.
I believe the TLV = (0x00 0x00) form a regular acceptable
TLV, and can
also serve as a termination-indicator in case of indefinite
encoding.
Consider the example:-
( T1 L1 (T2 L2 V2) (T3 L3 V3) (00 00) (00 00) ) (T4 L4 V4)
^
( T1 L1 (T2 L2 V2) (T3 L3 V3) (00 00) ) (00 00) (T4 L4 V4)
^ where L1 = 0x80.
Which one of the above two cases is legal ?
If neither L2 nor L3 have indefinite length form (and they
both have definite form, judging from your way of putting
braces around the TLV tuples), then the second case is legal.
The indefinite form basically pushes the expectation of
end-of-content octets to the decoding stack. Every time the
next TLV at the T1 level is found, it is checked whether it
is end-of-content sequence. The first end-of-content bytes at
the T1 level will serve as a terminator for the T1 sequence.
Please note that if T2 or T3 have indefinite length forms,
they would "eat" the end-of-content octets closest to them:
T1 iL1 ; indefinite form
T2 iL2 ; indefinite form
...
00 00 ; terminates T2!
T3 L3 ; definite form
V3
00 00 ; terminates T1!
--
Lev Walkin
[EMAIL PROTECTED]
--
Lev Walkin
[EMAIL PROTECTED]
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1