[botan-devel] ASN.1 parsing: how to get complete TLV structure

Jack Lloyd lloyd at randombit.net
Fri Dec 6 14:41:42 EST 2013

On Fri, Dec 06, 2013 at 12:42:33PM +0000, Lösch, Sebastian wrote:
> I am parsing an ASN.1 structure and want to get an element's raw bytes, i.e. the complete TLV structure of an element as byte array.
> Assume the following structure:
> Parent::= SEQUENCE {
> childOne ChildOneType,
> childTwo ChildTwoType
> }
> I want to get the byte array of childOne.
> I start parsing with an instance of BER_Decoder holding the data of element Parent.
> BER_Decoder parentDecoder(...);
> Then I parse the sequence
>                 BER_Decoder childDecoder = parentDecoder.start_const(SEQUENCE);

If I'm understanding your question correctly childDecoder.raw_bytes(v)
should do what you want.

Cheers, J

More information about the botan-devel mailing list