i2d & ASN1_SEQUENCE related query in openssl 1.1.1.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

i2d & ASN1_SEQUENCE related query in openssl 1.1.1.

prudvi raj
Hi,
I am trying to write replacement ASN1 macros for i2d/d2i functions in openssl 1.1.1
Previously: 
typedef struct pkcs7_issuer_and_subject_st
{
    X509_NAME *issuer;          /* Certificate Issuer's name */
    X509_NAME *subject;         /* Certificate's subject name */
} PKCS7_ISSUER_AND_SUBJECT;
----
i2d function:
int i2d_PKCS7_ISSUER_AND_SUBJECT (PKCS7_ISSUER_AND_SUBJECT * a,
                                              unsigned char **pp)
 {
     M_ASN1_I2D_vars (a);
     M_ASN1_I2D_len (a->issuer, i2d_X509_NAME);
     M_ASN1_I2D_len (a->subject, i2d_X509_NAME); 
     M_ASN1_I2D_seq_total ();
     M_ASN1_I2D_put (a->issuer, i2d_X509_NAME);
     M_ASN1_I2D_put (a->subject, i2d_X509_NAME);
     M_ASN1_I2D_finish ();
 }

======================================
New :

DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SUBJECT) 

ASN1_SEQUENCE(PKCS7_ISSUER_AND_SUBJECT) = {
        ASN1_SIMPLE(PKCS7_ISSUER_AND_SUBJECT, issuer, X509_NAME),
        ASN1_SIMPLE(PKCS7_ISSUER_AND_SUBJECT, subject, X509_NAME)
} ASN1_SEQUENCE_END(PKCS7_ISSUER_AND_SUBJECT)

IMPLEMENT_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SUBJECT)

Finally , we can call the function : 
 ulLen = i2d_PKCS7_ISSUER_AND_SUBJECT (&pkcs7IssuerAndSub, &ptr);

Is this the correct way , or am I missing anything ??
( does it need  DECLARE_ASN1_ALLOC_FUNCTIONS  & DECLARE_ASN1_ITEM .. ...etc.,.)   
Can anyone help me out in this regard !!

Thanks,
Prudvi.