On Tue, Apr 03, 2012, Naveen Nathan wrote:

> Hi,
> 
> I'm trying to use the custom ASN1 facilities of openssl, but lack
> understanding of some aspects. At the end of I've included some
> test source code which attempts to encode and write out a custom
> ASN1 structure. Regarding the code I have a few questions:
> 
> 1. Does symmKeyInfo_new(), where symmKeyInfo is the custom ASN1
>    struct, allocate each field of the struct? Additionally, if I
>    used nested sequences, will it recursively allocate?
> 
>    Looking through debugging sessions, this appears to be what is
>    going on, but it's a little unclear.
> 

Yes except for OPTIONAL fields and the CHOICE type.

> 2. symmKeyInfo has the ASN1_OBJECT field 'usage'. If allocated using
>    symmKeyInfo_new(), how can I set the field?
> 
>    For example, 'payload' which is an ASN1_OCTET_STRING has available
>    ASN1_OCTET_STRING_set, which sets the field, reallocating 'payload'
>    if necessary.
> 
>    However digging through the openssl source I can't seem to find a
>    similar function for ASN1_OBJECT type.
> 

That's because the ASN1_OBJECT is a little different. Some standard OIDs are
set to a fixed value to avoid the need to keep allocating them. What that
means in practice is you do something like:

foo->usage = OBJ_something(somearg);

This wont result in a memory leak because the OID isn't dynamically allocated.

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to