JonathanWilbur / asn1-ts

ASN.1 TypeScript library, including codecs for Basic Encoding Rules (BER) and Distinguished Encoding Rules (DER).
MIT License
32 stars 6 forks source link

ber decoding for non short tag number #10

Closed hamano closed 4 years ago

hamano commented 4 years ago

BER decos will fail such as: 0x1F, 0x04, 0x03, 0x01, 0x02, 0x03 Yes, this byte sequence can be minimized: 0x04, 0x03, 0x01, 0x02, 0x03

I undertand that the minimize rule is applied to DER, not BER.

ref: http://luca.ntop.org/Teaching/Appunti/asn1.html

DER adds the following restrictions to the rules given in Section 3:

When the length is between 0 and 127, the short form of length must be used

Checklist

JonathanWilbur commented 4 years ago

You are right! Excellent catch! I will merge, update the version number, and publish a new version. Thanks for your help!