Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6237027

Incorrect ASN.1 encoding of Enumerated types

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 5.0
    • security-libs
    • None
    • beta
    • generic, x86
    • generic, windows_2000


      An issue with Java ASN.1 encoding of Enumerated value:-

      ASN.1 encoding created by putEnumerated() cannot be read by getEnumerated().

      ASN spec for Enumerated encoding says:
      "The encoding of emerated value shall be that of the integer value with
      which it is associated.
      NOTE: It is primitive"

      When creating an Enumerated encoding of an integer, we call into the
      integer encoding, after inserting the required tag for enumerated type.

      public void putEnumerated(int i) throws IOException {
       write(DerValue.tag_Enumerated);
       putInteger(i);
      }

      However, the code for encoding the integer value also inserts the tag
      for the integer type.

      Hence, when encoding the integer (value 0) as an enumerated type, this
      results in:-
      0a 02 01 00, where:-
      0a is the tag for enumerated field
      02 is the tag for Integer field.

      This seems to be incorrect, we only need to insert the integer value
      here without the integer tag; the encoding should have been "0a 01 00".

      When reading the enumerated encoding using getEnumerated(), we actually
      FAIL to read the encoding generated by putEnumerated(int), due to the
      additional integer tag 02. If the integer tag is removed, getEnumerated
      seems to read it correctly.

      This issue does not exist in J2SE 1.4. Seems like it was introduced when adding the change for BigInt in DER code for Enumerated value, starting from J2SE 1.5.0.

      ###@###.### 2005-03-07 19:33:33 GMT

            smalkanisunw Seema Malkani (Inactive)
            smalkanisunw Seema Malkani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: