On Fri, Mar 18, 2005, Eric Alata wrote: > Hello, > > I would like to use openssl/asn1 with these types: > > TA ::= CHOICE { > f1 SET OF TA, > f2 TA, > f3 INTEGER > } > > TB ::= SEQUENCE { > f1 INTEGER, > f2 CHOICE { > f2_1 INTEGER, > f2_2 BOOLEAN > } > } > > I have two problems but I don't have found any > responses on Internet. > > 1) The definition of TA is recursive: it refers itself. > If I write: > > 1 typedef struct _ta_st TA; > 2 > 3 struct _ta_st { > 4 int type; > 5 union { > 6 STACK_OF(TA) *f1; > 7 TA *f2; > 8 ASN1_INTEGER *f3; > 9 } value; > 10 }; > 11 > 12 ASN1_CHOICE(TA) = { > 13 ASN1_SET_OF(TA, value.f1, TA), > 14 ASN1_SIMPLE(TA, value.f2, TA), > 15 ASN1_SIMPLE(TA, value.f3, ASN1_INTEGER) > 16 } ASN1_CHOICE_END(TA) > > the lines 13 and 14 do not pass the compilation. > The problem is that the field item of the structure > ASN1_TEMPLATE_st, on line 13, refers to > ASN1_ITEM_ref(TA) == TA_it. However, TA_it is > created only on line 16. With cpp: >
If you'd used a DECLARE_ASN1_XXX macro in a header file or before that it should compile. However because its ambiguous it wont work properly. > > 2) For the definition of TB, I think that there are two > solutions: > 2_1) Creating two structure: TB_CHOICE and TB. TB_CHOICE is > declared in the same way as TA. Then, TB just refers to ASN1_INTEGER > and TB_CHOICE. > That looks OK. > 2_2) Creating only one structure containing an ASN1_INTEGER and > an union. Then using ASN1_ADB to inform the structure ASN1_TEMPLATE. > That wont work becasue it isn't an "ANY DEFINED BY" type. Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Funding needed! Details on homepage. Homepage: http://www.drh-consultancy.demon.co.uk ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]