Tk Library Source Code

View Ticket
Login
Ticket UUID: 1645333
Title: asnGetContext fails if encoding is primitive
Type: Bug Version: None
Submitter: vbwagner Created on: 2007-01-26 14:24:52
Subsystem: asn Assigned To: mic42
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-04-21 01:38:00
Resolution: Fixed Closed By: mic42
    Closed on: 2007-04-20 18:38:00
Description:
Currently (as of version 0.7 of asn package) function asnGetContext  contain following check

   if {($tag & 0xE0) != 0x0a0} {
        return -code error \
            [format "Expected Context (0xa0), but got %02x" $tag]
   }

This check true if context-dependent tag has constructed encoding. However it is possible to have context-dependent tag with primitive encoding. For example, in PKCS7 format encrypted message data are stored as context-dependent tag with primitive encoding.

So, this check should be relaxed as 

  if {($tag & 0xC0) != 0x80} 

for more strict conformance with BER. It would be very nice to add additional optional parameter "encodingType" to asnGetContext, which would return value of 0x20 bit of the tag, thus letting application to know whether encoding of this tag was constructed or primitive.

Simular changes should be applied to asnGetApplication, which has the same problem.
User Comments: mic42 added on 2007-04-21 01:38:00:
Logged In: YES 
user_id=302287
Originator: NO

Fixed in asn 0.8.

mic42 added on 2007-02-09 05:31:59:
Logged In: YES 
user_id=302287
Originator: NO

Agreed, that there is a problem with too strict checks in some places, there is also a RFE talking about a similar issue. I'll give it a bit more thought, as there are other issues like decoding CHOICE and SET structures, which is currently quite cumbersome, which would also need relaxed tag type checking and tag introspection to select the correct decoding (similar to the current string decoder).

vbwagner added on 2007-01-26 21:29:16:

File Added - 213235: asn.tcl.diff

Logged In: YES 
user_id=757679
Originator: YES

File Added: asn.tcl.diff

Attachments: