home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.protocols.iso
- Path: sparky!uunet!walter!porthos!maestro!rkc
- From: rkc@maestro.bellcore.com (Ramakrishna Chamarthy)
- Subject: Re: Question on ASN.1 Encodings
- Organization: Bellcore (Red Bank, NJ)
- Date: Fri, 20 Nov 92 16:24:35 GMT
- Message-ID: <1992Nov20.162435.23241@porthos.cc.bellcore.com>
- References: <1drej9INN8t8@svcase.sp.paramax.com>
- Sender: netnews@porthos.cc.bellcore.com (USENET System Software)
- Lines: 66
-
- In article <1drej9INN8t8@svcase.sp.paramax.com> scase@email.sp.paramax.com (Steve Case) writes:
- >I am trying to understand the various ASN.1 encoding and I cannot seem
- >to understand how the indefinite form for the length octets can possibly
- >work! To make things simple, let me give you a specific example and
- >hopefully someone can clarify the situation for me.
- >
- >Let's assume we are encoding a bitstring value. The particular bitstring
- >to be encoded is '0900000009'H. If I use the indefinite length format,
- >wouldn't this be encoded as follows:
- >
- > BitString Length Contents
- > 23 80 000900000009
- >
- > EOC Length
- > 00 00
- >
- >
- >My question, then, is when decoding this octet stream, how do you know
- >that the bitstring is '0900000009'H and not '09'H or '090'H or '0900'H
- >or '09000'H? All three of these seem to be possible decodings?
- >
-
- First of all a correction to your 'correction posting' (second posting that
- I did not include) -
-
- No, The Bit String Identifier should be '23' (instead of '03') as mentioned in
- your posting (the first reaction is the correct reaction) :-), as opposed to
- the correction ('03') mentioned in your second posting.
-
- The reason is, although,
- a Bit string can be encoded in Primitive Form (identifier '03') OR
- Constructor Form (identifier '23'),
- you can encode only in Constructor Form using EOC.
-
- If it is Primitive Form, it will be encoded as
-
- Bit String Length Contents
- 03 06 000900000009
-
- If it is Constructor Form, you can encode it in many ways
- Two of the ways are -
-
- Bit String Length Contents
- 23 80
- Bit String Length Contents
- 03 06 000900000009
- EOC Length
- 00 00
- OR
-
- Bit String Length Contents
- 23 80
- Bit String Length Contents
- 03 04 00090000
- Bit String Length Contents
- 03 03 000009
- EOC Length
- 00 00
-
- I think, you mixed up the encodings of the Primitive Form and Constructor
- Form for the Bit String in your example - and hence the confusion.
-
- Hope this helps.
-
- - Ramakrishna E-mail: rkc@maestro.bellcore.com
-
-