Nice tip. I'll look into that.
On Thu, Sep 22, 2011 at 4:19 AM, Frank Morgner <frankmorg...@gmx.de> wrote: > On Thursday, September 22 at 08:41AM, Dominik Oepen wrote: > > > > Am 21.09.2011 23:27, schrieb Chang Lee: > > > Does anyone know of a way to take an ASN1_OCTET_STRING that contains a > > > DER encoded Sequence and extract the contents of the Sequence as an > > > ASN1_STRING. Essentially, I want to construct an ASN1 object of the > > > Sequence. I guess I could manually parse the Sequence (and deal with > > > the different types of length encoding) but I figure there must be an > > > easier way. > > > > You can use the macros in asn1t.h for parsing DER encoded data. Have a > > look at the comment starting at line 132 (I'm using OpenSSL 1.0.0e) of > > this header file. It explains how to declare an ASN1 SEQUENCE. You can > > find plenty of examples using these macros within the OpenSSL source > > (for example crypto/pkcs7/p7_asn1.c). > > An other approach would be to strip tag and length from the octet string > with ASN1_get_object. Then use ASN1_put_object to wrap the data into a > sequence. > > Cheers, Frank. >