Difference ASN1_item_d2i_bio / ASN1_d2i_bio_of ?

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

Difference ASN1_item_d2i_bio / ASN1_d2i_bio_of ?

Lynch, Andrew
Hi,

I want to read several bespoke ASN1 types from a BIO.  DECLARE_ASN1_FUNCTIONS does not include d2i bio routines, so what is the best way to define them?

I have seen both ASN1_item_d2i_bio() and ASN1_d2i_bio_of() and it is not clear to me why one might be used over the other.

E.g. cms_io.c has a one-line function calling ASN1_item_d2i_bio():

        CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms)
        {
            return ASN1_item_d2i_bio(ASN1_ITEM_rptr(CMS_ContentInfo), bp, cms);
        }

Whereas ocsp.h has a macro using ASN1_d2i_bio_of, which itself is defined in terms of ASN1_d2i_bio():

        #  define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p)

Regards,
Andrew.