Rich Salz wrote:
> 
> > Now it would be possible to change the ASN1 code to use either function
> > pointers or a hybrid of optional function pointers where needed. Since
> > most of this stuff is implemented and declared through macros this isn't
> > too painful.
> 
> You can do it like ANSI says for errno.
> 
> #ifdef GOOD_LINKER
> extern ASN1_ITEM* ku_item;
> #else /* BAD_LINKER */
> #define ku_item asn1_item_lookup(ku_item_nid)
> extern ASN1_ITEM* asn1_item_lookup(int);
> #endf
> 
> Then developers get source compatibility.

There are a couple of problems with that as it stands. One minor issue
is that the current code declares ASN1_ITEM as extern e.g.

extern ASN1_ITEM ASN1_OCTET_STRING_it;

and the macros turn it into &ASN1_OCTET_STRING_it. Easy enough to change
though.

The main problem is that the various addresses need to be resolved at
compile time. You'll have a structure where one element is initialised
to "ku_item" in that example. It would be legitimate to give it a
function pointer and place 'nid' somewhere though. However you then get
the additional problem of how you get any new ASN1_ITEM structures
declared by an external program or library into this model and in such
as way that other programs or libraries can initialise them at compile
time.

Currently the best thing I can think of is something like:

coinst ASN1_ITEM *ASN1_OCTET_STRING_it(void) {
        static const ASN1_ITEM ASN1_OCTET_STRING_internal = {/* Some definition
*/};
        return &ASN1_OCTET_STRING_internal;
}

and then you place a function pointer ASN1_OCTET_STRING_it in the
structures that need to access it and it is converted at runtime. You'd
then have various macros that select whichever method was appropriate on
the particular platform and act appropriately.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.

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

Reply via email to