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: const static ASN1_TEMPLATE TA_ch_tt[] = { { ((0x1 << 1)), (0), ((size_t) &((TA *)0)->value.f1), "value.f1", (&(TA_it)) }, { (0), (0), ((size_t) &((TA *)0)->value.f2), "value.f2", (&(TA_it)) }, { (0), (0), ((size_t) &((TA *)0)->value.f3), "value.f3", (&(ASN1_INTEGER_it)) } } ; const ASN1_ITEM TA_it = { 0x2, ((size_t) &((TA *)0)->type) , TA_ch_tt, sizeof(TA_ch_tt) / sizeof(ASN1_TEMPLATE), ((void *)0), sizeof(TA), "TA" }; Maybe would I use ASN1_OBJECT instead ? For exemple: 13 ASN1_SET_OF(TA, value.f1, ASN1_OBJECT), 14 ASN1_SIMPLE(TA, value.f2, ASN1_OBJECT), But, I am not sure that it is a good solution. Could you help me to resolve this problem ? 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. 2_2) Creating only one structure containing an ASN1_INTEGER and an union. Then using ASN1_ADB to inform the structure ASN1_TEMPLATE. I think the two solutions are corrects. Could you tell me, please, which one is the best ? Thanks. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]