Skip to content

Decoding nested ASN.1 sequences with implicit tags #2080

Closed Answered by peterdettman
onyn asked this question in Q&A
Discussion options

You must be logged in to vote

An ASN.1 parser cannot (in the general case) resolve a tag without external information. Especially implicit tagging requires to be told, at parse-time, what the correct tag actually is (implicit tagging elides the original tag). Parsing isn't really complete until all tagging has been resolved.

Example of "completing parsing" in this case:
var obj = encodeDecode("seq.der", SEQ);
var tag = ASN1TaggedObject.getInstance(encoded, BERTags.CONTEXT_SPECIFIC, 1); // Tag validation
var seq = ASN1Sequence.getInstance(tag, false); // ASN.1 types should usually provide a getInstance method like this

You'll see that this reconstructs the two different sequences correctly.

BTW, the two instances of DL…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by onyn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants