wstrange/asn1lib

Unrecognized application tags throw an error instead of creating a generic object

point-source opened this issue · 1 comments

The current implementation of the ASN1Parser checks to see if the tag is primitive or application. If the tag is application, it checks to see if it is based on a sequence. If so, it parses as a sequence. If not, it throws an error. What's strange is that if the tag is neither primitive nor application (and is thus either context-specific or universal), the parser goes ahead and creates a generic ASN1Object.

Is there a reason why we allow generic objects in context-specific or universal space but not within application space? From what I understand, application are any tags that might exist in say LDAP but not in SNMP or vice-versa. I assume that means that an LDAP tag may have the same code as an SNMP tag but mean different things. I have struggled to find documentation to confirm/deny this.

If this is not the case, and all application-based tags are unique/reserved, I would like to add additional tags to this library so they may be recognized. If this is the case, and application tags may mean different things to different applications, then I propose we allow generic objects to be created when an application tag is not recognized.

Relevant code here: https://github.com/wstrange/asn1lib/blob/master/lib/asn1parser.dart#L57

The ASN1 spec is very non obvious to me - but what you are proposing makes sense. I can retest the dartdap ldap library if you create a new version. LDAP is a pretty good way of shaking out encoding problems.