The 0000 is only a terminator when it appears at a point where a TL in the TLV
is expected.
That is why indefinite length encodings are only allowed for a V in the TLV that
is a CONSTRUCTED encoding, that is Vs that are a sequence of TLV encodings (such
as SEQUENCE or SEQUENCE OF etc), not for Vs that are primitive encodings (raw
data) such as INTEGER, etc.
Note that for OCTET STRING, the V can be encoded as either primitive (no
indefinite length allowed) or as a series of TLV fragments terminated by the 0000.
John L
Banibrata Dutta wrote:
Hi,
This is the reincarnation of an old question posted to this group.
If I am using indefinite form of encoding, and my value itself needs to
contain "00 00", then isn't the decoder confused when it sees the "00 00",
as it could mean that it's the terminal marking end-of-value, or a part of
the value ?
regards,
bdutta
-----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]
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1
--
Prof John Larmouth
Larmouth T&PDS Ltd
(Training and Protocol Development Services Ltd)
1 Blueberry Road
Bowdon [EMAIL PROTECTED]
Cheshire WA14 3LS
England
Tel: +44 161 928 1605 Fax: +44 161 928 8069
_______________________________________________
ASN1 mailing list
[email protected]
http://lists.asn1.org/mailman/listinfo/asn1