Ben Laurie wrote:
> 
> Dr Stephen Henson wrote:
> >
> > Scheltema, R.A. wrote:
> > >
> > > Hi all,
> > >
> > > I'm currently working on an implementation of a program using openssl. In
> > > this program it would be extremely usefull if I could pass data to the
> > > callback-functions in the way, for example, the thread call-back method is
> > > done (or x-event-methods, ...). The password method would look like:
> > >
> > > struct myData {
> > >    // ...
> > > };
> > >
> > > static int __supply_passwd(char *buf, int len, int WhatIsThis, void *data) {
> > >    struct myData *md = (myData *) data;
> > >    // ...
> > > }
> > >
> > > int main() {
> > >    myData *d = new myData;
> > >    SSL_CTX_set_default_passwd_cb(m_ctx, &__supply_passwd, (void *) d);
> > >    // ...
> > >    return 0;
> > > }
> > >
> > > With the current situation it is, according to me, impossible to do this. Or
> > > am I wrong? If not is it an option for future releases ??
> > >
> >
> > I think the best you can currently do is either have one callback for
> > each piece of data or some yucky global variable version with thread
> > specific data and appropriate locks.
> >
> > Adding an extra parameter to the password callbacks is a much cleaner
> > way of handling things. Unfortunately lots of functions use them (e.g.
> > PEM stuff) and it will break quite a lot of code (but all they will need
> > is an extra parameter set to NULL) and its rather a large change.
> >
> > It is IMHO well worth doing so it may well appear in a future release.
> 
> You can already add "extra" data to the context, IIRC, so perhaps the
> neater solution is to pass the context to the callback?
> 

Yes that would probably be better when the stuff gets called via SSL but
we'd still need to modify PEM_read_* stuff which is called internally to
pass the context to the callback. 

So if were going to do that then we might as well allow the extra
parameter on any PEM_read/PEM_write function anyway.

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