home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / protocol / iso / devenvi / 229 < prev    next >
Encoding:
Internet Message Format  |  1992-11-19  |  2.7 KB

  1. Path: sparky!uunet!dziuxsolim.rutgers.edu!caip.rutgers.edu!baos
  2. From: baos@caip.rutgers.edu (Bancroft Scott)
  3. Newsgroups: comp.protocols.iso.dev-environ
  4. Subject: Re: Question on ASN.1 Encodings
  5. Message-ID: <Nov.20.13.00.58.1992.14833@caip.rutgers.edu>
  6. Date: 20 Nov 92 18:00:58 GMT
  7. References: <1drf0lINN8up@svcase.sp.paramax.com>
  8. Organization: Rutgers Univ., New Brunswick, N.J.
  9. Lines: 67
  10.  
  11. scase@email.sp.paramax.com (Steve Case) writes:
  12.  
  13. >Let's assume we are encoding a bitstring value.  The particular bitstring
  14. >to be encoded is '0900000009'H.  If I use the indefinite length format, 
  15. >wouldn't this be encoded as follows:
  16.  
  17. >   BitString Length Contents
  18. >   03        80     000900000009
  19. >   EOC       Length
  20. >   00        00
  21.  
  22. >My question, then, is when decoding this octet stream, how do you know
  23. >that the bitstring is '0900000009'H and not '09'H or '090'H or '0900'H
  24. >or '09000'H?  All three of these seem to be possible decodings?
  25.  
  26. In the above I changed your original identifier octet from '23' to '03' as
  27. you requested in your followup mail.
  28.  
  29. Clause 6.3.2.c of ISO 8825 states "use the indefinite form if the
  30. encoding is constructed".  Since the above encoding has the
  31. primitive/constructed bit set to 0, indicating that the encoding is
  32. primitive, the indefinite form cannot be used in encoding the bit
  33. string, hence the encoding should be:
  34.  
  35.    BitString Length Contents
  36.    03        06     000900000009
  37.  
  38.  
  39. However, if we consider the example in your original message:
  40.  
  41. >   BitString Length Contents
  42. >   23        80     000900000009
  43. >   EOC       Length
  44. >   00        00
  45.  
  46. we see that since in this case the encoding has the
  47. primitive/constructed bit set to 1, indicating that the encoding is
  48. constructed, the indefinite length form can be used.  However, the
  49. Contents must eventually be a primitive encoding of the actual bit
  50. string value, or of several bit string values that together form the
  51. original value.  A proper encoding for the above is:
  52.  
  53.    BitString Length Contents
  54.    23        80
  55.             BitString Length Contents
  56.             03        06     000900000009
  57.    EOC       Length
  58.    00        00
  59.  
  60. So why bother using indefinite length form?  So that you can start
  61. the encoding process without knowing ahead of time the total length
  62. of the value.  For example:
  63.  
  64.    BitString Length Contents
  65.    23        80
  66.             BitString Length Contents
  67.             03        04     00090000
  68.             03          03     000009
  69.    EOC       Length
  70.    00        00
  71.  
  72. See ISO 8825 clause 11.3 for details.
  73.  
  74. =====================================|========================================
  75. Bancroft Scott                 |        Open Systems Solutions, Inc.
  76. 609-987-9073                 |        Princeton, N.J.
  77. =====================================|========================================
  78.