home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / protocol / iso / 1367 < prev    next >
Encoding:
Text File  |  1992-11-20  |  2.4 KB  |  78 lines

  1. Newsgroups: comp.protocols.iso
  2. Path: sparky!uunet!walter!porthos!maestro!rkc
  3. From: rkc@maestro.bellcore.com (Ramakrishna Chamarthy)
  4. Subject: Re: Question on ASN.1 Encodings
  5. Organization: Bellcore (Red Bank, NJ)
  6. Date: Fri, 20 Nov 92 16:24:35 GMT
  7. Message-ID: <1992Nov20.162435.23241@porthos.cc.bellcore.com>
  8. References: <1drej9INN8t8@svcase.sp.paramax.com>
  9. Sender: netnews@porthos.cc.bellcore.com (USENET System Software)
  10. Lines: 66
  11.  
  12. In article <1drej9INN8t8@svcase.sp.paramax.com> scase@email.sp.paramax.com (Steve Case) writes:
  13. >I am trying to understand the various ASN.1 encoding and I cannot seem
  14. >to understand how the indefinite form for the length octets can possibly
  15. >work!  To make things simple, let me give you a specific example and
  16. >hopefully someone can clarify the situation for me.
  17. >
  18. >Let's assume we are encoding a bitstring value.  The particular bitstring
  19. >to be encoded is '0900000009'H.  If I use the indefinite length format, 
  20. >wouldn't this be encoded as follows:
  21. >
  22. >   BitString Length Contents
  23. >   23        80     000900000009
  24. >
  25. >   EOC       Length
  26. >   00        00
  27. >
  28. >
  29. >My question, then, is when decoding this octet stream, how do you know
  30. >that the bitstring is '0900000009'H and not '09'H or '090'H or '0900'H
  31. >or '09000'H?  All three of these seem to be possible decodings?
  32. >
  33.  
  34. First of all a correction to your 'correction posting' (second posting that
  35. I did not include) -
  36.  
  37. No, The Bit String Identifier should be '23' (instead of '03') as mentioned in 
  38. your posting (the first reaction is the correct reaction) :-), as opposed to 
  39. the correction ('03') mentioned in your second posting. 
  40.  
  41. The reason is, although, 
  42. a Bit string can be encoded in Primitive Form (identifier '03') OR 
  43. Constructor Form (identifier '23'),
  44. you can encode only in Constructor Form using EOC. 
  45.  
  46. If it is Primitive Form, it will be encoded as
  47.  
  48. Bit String    Length    Contents
  49. 03        06    000900000009
  50.  
  51. If it is Constructor Form, you can encode it in many ways
  52. Two of the ways are - 
  53.  
  54. Bit String    Length     Contents
  55. 23          80    
  56.             Bit String    Length    Contents
  57.             03        06    000900000009
  58.             EOC        Length
  59.             00        00
  60. OR
  61.  
  62. Bit String    Length     Contents
  63. 23          80    
  64.             Bit String    Length    Contents
  65.             03        04    00090000
  66.             Bit String    Length    Contents
  67.             03        03    000009
  68.             EOC        Length
  69.             00         00
  70.  
  71. I think, you mixed up the encodings of the Primitive Form and Constructor
  72. Form for the Bit String in your example - and hence the confusion.
  73.  
  74. Hope this helps.
  75.  
  76. - Ramakrishna            E-mail: rkc@maestro.bellcore.com
  77.  
  78.