[openssl-users] how to implement functions for STACK OF custom type?

lists lists at rustichelli.net
Mon Mar 27 18:01:12 UTC 2017


On 03/24/2017 06:46 PM, Dr. Stephen Henson wrote:
> On Tue, Mar 21, 2017, lists wrote:
>
>> Sorry, I first posted this on the -dev list, likely inappropriate... now with an update:
>>
>> I am exploring my options with OpenSSL and specifically I am trying to manage the stacks for some custom objects.
>> Currently, I have this code (sort of) in the headers:
>>
>> typedef struct myThingA_st
>> {
>>       ASN1_OBJECT aID;
>>       ASN1_OCTET_STRING aOCST;
>> }
>>       myThingA;
>>
>> DECLARE_ASN1_ITEM(myThingA)
>> DECLARE_ASN1_FUNCTIONS(myThingA)
>> DECLARE_STACK_OF(myThingA)
>> [...]
> If you're using OpenSSL 1.1.0 you need to include:
>
> DEFINE_STACK_OF(FOO)
>
> in a header file and that should be it. That implements a set of inline
> functions that do the right thing.
>
> For OpenSSL versions before 1.1.0 it's a bit messier. The type specific
> STACK_OF functions are actually macros which are generated by the mkstack.pl
> script and appear in the safestack.h header file. If you want to create your
> own one way is to extract a type specific section from safestack.h, copy it
> to your own header file and do a search/replace for the new type.
>
> So for example extract the sk_OPENSSL_BLOCK macros and replace OPENSSL_BLOCK
> with FOO.
>
> Steve.
> --
> Dr Stephen N. Henson. OpenSSL project core developer.
> Commercial tech support now available see: http://www.openssl.org

Thank you very much, Steve. Seems I'm progressing now.




More information about the openssl-users mailing list