🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.protocols.iso.dev-environ
3 messages
3 total messages Started by Steve Case Wed, 11 Nov 1992 17:13
Question on ASN.1 Encodings
#673
Author: Steve Case
Date: Wed, 11 Nov 1992 17:13
25 lines
1297 bytes
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?

Thank you for any assistance you might be able to give me.

Regards,
Steve Case
scase@planet8.sp.paramax.com
Re: Question on ASN.1 Encodings
#672
Author: Steve Case
Date: Wed, 11 Nov 1992 17:39
7 lines
662 bytes
Sorry, but I made a mistake in my encoding.  The identifier octet should
have been '03'H and not '23'H.  Other than that, the question should be
ok.

Regards,
Steve Case
scase@planet8.sp.unisys.com
Re: Question on ASN.1 Encodings
#675
Author: Bancroft Scott
Date: Fri, 20 Nov 1992 18:00
67 lines
2814 bytes
scase@email.sp.paramax.com (Steve Case) writes:

>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
>   03        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?

In the above I changed your original identifier octet from '23' to '03' as
you requested in your followup mail.

Clause 6.3.2.c of ISO 8825 states "use the indefinite form if the
encoding is constructed".  Since the above encoding has the
primitive/constructed bit set to 0, indicating that the encoding is
primitive, the indefinite form cannot be used in encoding the bit
string, hence the encoding should be:

   BitString Length Contents
   03        06     000900000009


However, if we consider the example in your original message:

>   BitString Length Contents
>   23        80     000900000009
>   EOC       Length
>   00        00

we see that since in this case the encoding has the
primitive/constructed bit set to 1, indicating that the encoding is
constructed, the indefinite length form can be used.  However, the
Contents must eventually be a primitive encoding of the actual bit
string value, or of several bit string values that together form the
original value.  A proper encoding for the above is:

   BitString Length Contents
   23        80
		    BitString Length Contents
		    03        06     000900000009
   EOC       Length
   00        00

So why bother using indefinite length form?  So that you can start
the encoding process without knowing ahead of time the total length
of the value.  For example:

   BitString Length Contents
   23        80
		    BitString Length Contents
		    03        04     00090000
		    03	      03     000009
   EOC       Length
   00        00

See ISO 8825 clause 11.3 for details.

=====================================|========================================
Bancroft Scott			     |		Open Systems Solutions, Inc.
609-987-9073			     |		Princeton, N.J.
=====================================|========================================
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads