Horray...that is it.  Thanks!!! 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Edward Chan
> Sent: Thursday, July 21, 2005 11:00 AM
> To: openssl-users@openssl.org
> Subject: RE: d2i_RSAPublicKey doesn't work
> 
> So I need to save buf to a tmp first like with d2i_RSAPublicKey?
> 
> Like this:
> 
> int len = i2d_RSAPublicKey(rsa, 0);
> unsigned char* buf = new unsigned char[len]; unsigned char* 
> tmp = buf; i2d_RSAPublicKey(rsa, &tmp);
> 
> // now use buf to decode
> 
> Is this correct?
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf Of Dr.
> > Stephen Henson
> > Sent: Thursday, July 21, 2005 10:23 AM
> > To: openssl-users@openssl.org
> > Subject: Re: d2i_RSAPublicKey doesn't work
> > 
> > On Thu, Jul 21, 2005, Edward Chan wrote:
> > 
> > > The code is basically like this:
> > > 
> > >   int len = i2d_RSAPublicKey(rsa, 0);
> > > 
> > >   // allocate buffer
> > >   unsigned char* buf = new unsigned char[len];
> > > 
> > >   // now call again to DER encode the public key
> > >   if (i2d_RSAPublicKey(rsa, &buf) == len)
> > >   {
> > > 
> > > I've also tried creating the RSA object first, and passing it into
> > > d2i_RSAPublicKey() for it to fill in.  It also returns me 
> null back.
> > > Does the code look right?
> > > 
> > 
> > No, this code is wrong for the reasons mentioned in the FAQ. 
> > After this call 'buf' points to garbage and that's why
> > d2i_RSAPublicKey() is failing.
> > 
> > Steve.
> > --
> > Dr Stephen N. Henson. Email, S/MIME and PGP keys: see 
> homepage OpenSSL 
> > project core developer and freelance consultant.
> > Funding needed! Details on homepage.
> > Homepage: http://www.drh-consultancy.demon.co.uk
> > 
> ______________________________________________________________________
> > 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]
> 
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to