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

Incorrect OBJECT IDENTIFIER validation #2

Closed JonathanWilbur closed 6 years ago

JonathanWilbur commented 6 years ago

This library incorrectly validates OBJECT IDENTIFIERs.

https://github.com/JonathanWilbur/asn1-ts/blob/9f524f5894ca4bf97db96bc38776091873109f7d/source/types/objectidentifier.ts#L12-L16

In the lines above, a possibly non-existent third node is checked (having index 2), which is a one-off error. Then, the alternative condition, where the first node is 2, the first node is checked again for being greater than 175, which is obviously contradictory with the first condition. This is two bugs in one expression!

JonathanWilbur commented 6 years ago

Fixed in version 1.2.0.