Bodo Moeller wrote:
> 
> 
> The clean way (and not just another "clever hack") would be
> 
> void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl,
>                                                           int is_export,
>                                                           int keylength))
>     {
>     RSA *(**cb_ptr)(SSL *, int, int) = &cb; /* cb_ptr is a data pointer,
>                                              * not a function pointer */
>     SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,cb_ptr); /* no cast necessary as
>                                                          * SSL_CTX_ctrl should
>                                                          * have "void *" in the
>                                                          * final argument */
>     }
> 
> and in ssl3_ctrl (which is what SSL_CTX_ctrl ends up calling):
> 
> long ssl3_ctrl(SSL *s, int cmd, long larg, void *parg)
>         {
>         [...]
> 
>         switch (cmd)
>                 {
>         [...]
> 
>         case SSL_CTRL_SET_TMP_RSA_CB:
>                 {
>                 RSA *(**cb_ptr)(SSL *, int, int) = parg;
> 
>                 s->cert->rsa_tmp_cb = *cb_ptr;
>                 }
>                 break;
>         [...]
>                 }
>         [...]
>         }
> 
> Instead of directly passing function pointers in disguise, a pass
> pointers to data objects containing the actual function pointers.
> 

Hmmm.... that will change the SSL_ctrl() behaviour but that shouldn't be
called directly anyway.

The BIOs are a little more awkward for example we've got
BIO_set_info_callback() currently defined as a macro casting the
callback to (char *). I'd suggest we use a similar technique and zap the
macro. The macros that do this kind of thing want replacing with real
functions anyway.

It will break binary compatibility but I can't think of any alternative.
It shouldn't matter too much anyway. So much has changed since 0.9.4
most application should be recompiled anyway.

I can't think of anywhere where we have a stack of function pointers. 
The EX_DATA stuff has them wrapped up in a strucure. Hmm... I've just
had a look, its a plain STACK, not STACK_OF and has no prototypes on the
function pointers either. It needs fixing.

> (SSL_CTX_ctrl, ssl3_ctrl et al. still have a char * argument where
> they should have a void * -- it's certainly trivial to change that.)

Yes thats a legacy from the pre-ANSI days. It, and a few others, should
be changed and a few (char *) casts deleted as well.

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