simple_asn1 icon indicating copy to clipboard operation
simple_asn1 copied to clipboard

Empty body is not necessarily an error

Open henris42 opened this issue 1 year ago • 1 comments

When decoding PKCS#7, you might see elements with empty body, like empty SET in this:

0 525: SEQUENCE { 4 9: OBJECT IDENTIFIER signedData (1 2 840 113549 1 7 2) 15 510: [0] { 19 506: SEQUENCE { 23 1: INTEGER 1 26 0: SET {} 28 11: SEQUENCE { 30 9: OBJECT IDENTIFIER data (1 2 840 113549 1 7 1) : }

This is valid PKCS#7, produced by EJBCA. OpenSSL accepts this fine.

However simple_asn1 fails this with EmptyBuffer. This means PKCS#7 is unparseable.

Empty bodies should be supported somehow to enable p7 parsing.

I forked the code and made SET return empty vector if its empty, but more generic solution should be created. One possibility might be an crate option that would make empty containers return empty vector? Thoughts?

henris42 avatar Aug 21 '24 13:08 henris42