That part of the code remains the same, and continues to work fine.  By
the way, my last code snippet should have been:

U8* tmp = buf;
RSA* pub = d2i_RSAPublicKey(0, (const U8**)&tmp, len); 

I mistakenly typed *len instead of len.

Anyways, after I call i2d_RSAPublicKey, calling d2i_RSAPublicKey does
not seem to work. It always returns me a null ptr.  But I know the RSA
object is fine.  I can use it in RSA_public_encrypt() and
RSA_private_decrypt().

Any ideas?  Anybody else experiencing this problem?


> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Nils Larsch
> Sent: Tuesday, July 19, 2005 12:36 AM
> To: openssl-users@openssl.org
> Subject: Re: d2i_RSAPublicKey doesn't work
> 
> Edward Chan wrote:
> > If you're referring to http://www.openssl.org/support/faq.html
> > 
> > 3. How do I read or write a DER encoded buffer using the 
> ASN1 functions?
> > 
> > ...
> > 
> > The opposite assumes we already have len bytes in buf:
> > 
> >  unsigned char *p;
> >  p = buf;
> >  p7 = d2i_PKCS7(NULL, &p, len);
> > 
> > At this point p7 contains a valid PKCS7 structure of NULL 
> if an error 
> > occurred. If an error occurred ERR_print_errors(bio) should 
> give more 
> > information.
> > 
> > The reason for the temporary variable 'p' is that the ASN1 
> functions 
> > increment the passed pointer so it is ready to read or 
> write the next 
> > structure. This is often a cause of problems: without the temporary 
> > variable the buffer pointer is changed to point just after the data 
> > that has been read or written. This may well be 
> uninitialized data and 
> > attempts to free the buffer will have unpredictable results 
> because it 
> > no longer points to the same address.
> > 
> > ------------------------------------------------------
> > 
> > I see where it says you need to create the temp var.  So changed my 
> > code to do that, but I still get a null ptr returned.
> > 
> > Code is now:
> > 
> >     U8* tmp = buf;
> >     RSA* pub = d2i_RSAPublicKey(0, (const U8**)&tmp, *len);
> 
> and what about i2d_RSAPublicKey ?
> 
> Nils
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    openssl-users@openssl.org
> Automated List Manager                           [EMAIL PROTECTED]
> 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to