I found the error. At the end, the problem was a bad definition of
"Sub_seq100". I have fixed it and ASN1_CHOICE works fine now. Thanks to all.

Regards.

Fernando Moya Bernal.
University of Malaga. Spain.


> > Hi, I am having problems with CHOICE in the following ASN.1 sequence:
> >
> > ---------------------------------------------------------------------
> > DEFINITIONS IMPLICIT TAGS
> >
> > Sub_seq200 ::= SEQUENCE
> >     {
> >      sub_field1 Sub_seq100 OPTIONAL,
> >      sub_field2 [0] Sub_seq400 OPTIONAL
> >      }
> >
> > Seq1 ::= CHOICE
> >      {
> >      field1 Sub_seq100,
> >      field2 [0] Sub_seq200
> >      }
> >
> > ---------------------------------------------------------------------
> >
> > Implemented by:
> >
> > typedef struct Sub_seq200_st
> >     {
> >     Sub_seq100 *sub_field1;
> >     Sub_seq200 *sub_field2;
> >     }Sub_seq200;
> >
> > typedef struct Seq1_st
> >     {
> >     int type;
> >     union {
> >         char *ptr;
> >         Sub_seq100 *field1;
> >         Sub_seq200 *field2;
> >         }value;
> >     }Seq1;
> >
> > ASN1_SEQUENCE(Sub_seq200) = {
> >     ASN1_OPT(Sub_seq200,sub_field1, Sub_seq100),
> >     ASN1_IMP_OPT(Sub_seq200,sub_field2, Sub_seq400,0),
> > } ASN1_SEQUENCE_END(Sub_seq200)
> >
> > IMPLEMENT_ASN1_FUNCTIONS(Sub_seq200)
> >
> > ASN1_CHOICE(Seq1) = {
> >     ASN1_SIMPLE(Seq1, value.field1,Sub_seq100),
> >     ASN1_IMP(Seq1, value.field2,Sub_seq200, 0)
> > } ASN1_CHOICE_END(Seq1)
> >
> > IMPLEMENT_ASN1_FUNCTIONS(Seq1)
> >
> > Well, Seq1_new, Seq1_free and i2d_Seq1 functions work correctly and DER
> > output is right, but when I call d2i_Seq1 with DER output from i2d_Seq1,
it
> > returns NULL. I think it could be an incorrect definition of
> > ASN1_CHOICE(Seq1).
> >
> > Does Anybody know what is wrong?
> >
>
> See what error message you get with ERR_print_errors_fp(srderr);
>
> Steve.
> --
> Dr Stephen N. Henson.
> Core developer of the   OpenSSL project: http://www.openssl.org/
> Freelance consultant see: http://www.drh-consultancy.demon.co.uk/
> Email: [EMAIL PROTECTED], PGP key: via homepage.
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> Development Mailing List                       [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]
>
>

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to