[openssl-users] ASN1 & Recursive Structures definition

Richard Levitte levitte at openssl.org
Fri Dec 1 23:22:35 UTC 2017


In message <2c480bc2-3367-38e9-f4d8-3e7b37e42cb8 at openca.org> on Fri, 1 Dec 2017 12:14:54 -0700, "Dr. Pala" <director at openca.org> said:

director> I am trying to define an ASN1 structure similar to this:
director> 
director> ASN1_SEQUENCE(TEST) = {
director>     ASN1_SIMPLE(TEST, version, ASN1_INTEGER),
director>     ASN1_EXP_SEQUENCE_OF_OPT(TEST, otherTests, TEST, 0)
director> } ASN1_SEQUENCE_END(TEST)
director> 
director> IMPLEMENT_ASN1_FUNCTIONS(TEST) [**]
director> 
director> what is the correct procedure for doing that ? The problem
director> is that the "otherTests" field should be a sequence of
director> "TEST" structures, but defined like that it won't work.
director> 
director> Is there a way to solve the issue ? Or shall we use
director> something like ASN1_ANY to avoid the circular reference ?

Nope...  all it takes is a forward declaration:

    ASN1_SEQUENCE(TEST);
    ASN1_SEQUENCE(TEST) = {
        ASN1_SIMPLE(TEST, version, ASN1_INTEGER),
        ASN1_EXP_SEQUENCE_OF_OPT(TEST, otherTests, TEST, 0)
    } ASN1_SEQUENCE_END(TEST)
    
    IMPLEMENT_ASN1_FUNCTIONS(TEST)

(I tested that just now)

Cheers,
Richard

-- 
Richard Levitte         levitte at openssl.org
OpenSSL Project         http://www.openssl.org/~levitte/


More information about the openssl-users mailing list