🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.protocols.iso.dev-environ
Article #675

Re: Question on ASN.1 Encodings

#675
From: 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.
=====================================|========================================
Technical Details
Message-ID: <Nov.20.13.00.58.1992.14833@caip.rutgers.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!dziuxsolim.rutgers.edu!caip.rutgers.edu!baos
References: <1drf0lINN8up@svcase.sp.paramax.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dziuxsolim.rutgers.edu!caip.rutgers.edu!baos
From: baos@caip.rutgers.edu (Bancroft Scott)
Newsgroups: comp.protocols.iso.dev-environ
Subject: Re: Question on ASN.1 Encodings
Message-ID: <Nov.20.13.00.58.1992.14833@caip.rutgers.edu>
Date: 20 Nov 92 18:00:58 GMT
References: <1drf0lINN8up@svcase.sp.paramax.com>
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 67