Fernando,

I think all user-defined tags in a CHOICE (e.g., [0]) are EXPLICIT -- I could be wrong 
and don't have time to check right now (it's been a while ...).

So I think you want:

ASN1_EXP(Seq1, value.field2,Sub_seq200, 0)

Frank



                                                                                       
                                                 
                      "Fernando Moya"                                                  
                                                 
                      <[EMAIL PROTECTED]        To:       <[EMAIL PROTECTED]>          
                                           
                      >                         cc:                                    
                                                 
                      Sent by:                  Subject:  d2i and ASN1_CHOICE          
                                                 
                      owner-openssl-dev@                                               
                                                 
                      openssl.org                                                      
                                                 
                                                                                       
                                                 
                                                                                       
                                                 
                      06/26/2003 04:55                                                 
                                                 
                      AM                                                               
                                                 
                      Please respond to                                                
                                                 
                      openssl-dev                                                      
                                                 
                                                                                       
                                                 
                                                                                       
                                                 




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?

Thanks in advance.

Fernando Moya Bernal.
University of Malaga. Spain.

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





--

This e-mail may contain confidential and/or privileged information. If you are not the 
intended recipient (or have received this e-mail in error) please notify the sender 
immediately and destroy this e-mail. Any unauthorized copying, disclosure or 
distribution of the material in this e-mail is strictly forbidden.


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

Reply via email to