rusticata / der-parser

BER/DER parser written in pure Rust. Fast, zero-copy, safe.
Apache License 2.0
84 stars 29 forks source link

BerObject::as_pretty() drops tag class when printing Unknown contents #47

Closed lilyball closed 3 years ago

lilyball commented 3 years ago

BerObjectContent::Unknown carries the BerTag but not the BerClass. I don't know why this is, it seems like an oversight, but the class is stored in the BerObjectHeader. Unfortunately, the BerObject::as_pretty() method only prints the contents (barring the ShowHeader flag). What's more, it prints the enum name for any BerTags even if they don't belong to the Universal class. This means that my pretty-printed object is showing up containing a Sequence[Unknown(EndOfContent,[de, ad, be, ef])]. Printing the header tells me this is actually a context-specific tag, which means it should have been printed as something like Sequence[Unknown(ContextSpecific(0),[de, ad, be, ef])] instead.