On Thu, Jun 13, 2002 at 01:26:42PM +0200, Bodo Moeller via RT wrote:

> [[EMAIL PROTECTED] - Thu Jun  6 18:39:34 2002]:
> > It appears the openssl guys goofed in 0.97beta.  The prototype for the
> > d2i_RSAPrivateKey function in 0.9.6c, which I use, is like this:
> > 
> >     d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length);
> >     
> > ie., without a const on the second parameter.  The const should have
> > been done like this (I think):
> >     const unsigned char * const *pp
> > ...which would be entirely backwards-compatible with old versions of
> > openssl.
> 
> Could you explain why you think this would improve compatibility
> (compared with 'const unsigned char **pp', which is how 'pp' should
> be declared in 0.9.7-beta1, although the exact definition is
> hidden behind macros)?

Any variable that could be passed to a function taking "unsigned char **"
could also be passed to a function taking "const unsigned char * const *". 
Thus, using the above declaration would make openssl's api 100%
source-compatible with previous versions, while promising an increased level
of constness.

Using "const unsigned char **", however, is not 100% api-compatible, because
you can't safely pass an "unsigned char **" to it, for complicated reasons
explained in the URL I sent earlier.

> In fact the second 'const' would be wrong because the pointer that
> 'pp' points to is updated to reflect how much of the encoded data
> has been processed by the d2i_... function.  I.e., it is not
> at all constant.

Now, you caught me there.  The change I proposed earlier (adding an additional
"const") would fix API compatibility, but promises a level of constness that
you're not actually providing.

Unfortunately, I don't know a way around it: the problem is that the beta1
level of constness looks right, but doesn't _actually_ promise the constness
that it looks like it does, due to the crazy hackery described in the URL I
sent earlier.  It also makes the API incompatible with older versions.  I
can't pass the address of "unsigned char *p" to the new function.

On the other hand, I can't pass the address of "const unsigned char *p" to
the old-style function.

Neither situation is desirable... but it looks like you might have to just
use two different functions with two different APIs, unfortunately.  I don't
know another way out.

Have fun,

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

Reply via email to