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

Lösch, Sebastian slo at bos-bremen.de
Mon Dec 9 02:09:11 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
> _______________________________________________
> botan-devel mailing list
> botan-devel at randombit.net
> http://lists.randombit.net/mailman/listinfo/botan-devel

Unfortunately this does not work.

If I correctly understand the sources, 
          childDecoder.raw_bytes(v) 
reads until the end of the parent sequence, i.e. gets me the TLV of childOne AND childTwo. But I need only the TLV of childOne.

On the other hand moving to childOne by 
          BER_Object childOne = childDecoder.get_next_element();
only gives me the chance to access the value of childOne.




More information about the botan-devel mailing list