lapo-luchini / asn1js

JavaScript generic ASN.1 parser
ISC License
586 stars 161 forks source link

Bitstring parsing error #79

Closed olibu closed 8 months ago

olibu commented 10 months ago

ASN1 structures with bitstring starting with the "17 1E" and a length of 256 bit cannot be parsed correctly. The bitstring is interpreted as a date field.

Example of a CSR containing such a bitstring. Of course the CSR is not a valid on and the signature is not valid as well. However, the bitstring should be parseable correctly.

-----BEGIN CERTIFICATE REQUEST----- MIHBMHUCAQAwDzENMAsGA1UEAwwEdGVzdDAqMAUGAytlcAMhABceg8GyUYA/ht0B 6c+ohr6JpzFtg3JkmsIjHsZp+BqEoDMwMQYJKoZIhvcNAQkOMSQwIjALBgNVHQ8E BAMCBDAwEwYDVR0lBAwwCgYIKwYBBQUHAwEwBQYDK2VwA0EAm2DTuzGJx+ZLfZ5F S6UoPKuV9CDVW2NQBGRWr7E9JfkVlJi4AXp7fOjWggmUO+ddJvbPEesZaRllXZr4 xataBQ== -----END CERTIFICATE REQUEST-----

image

openssl is able to parse the CSR correctly:

image
olibu commented 10 months ago

In the method parseTime() in asn1.js it is correctly recognised that this is not a valid date. Would it be possible to ignore the date in case of a bitstring content type guess?