Markus Wagner wrote:
>
> Works, thanks!
>
> Markus
>
> "Barnes, Michael L." wrote:
> >
> > I've had success with BIO_get_mem_data(). I've never
> > played with BIO_get_mem_ptr().
> >
> > Mike
> >
> > > -----Original Message-----
> > > From: Markus Wagner [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, June 01, 2000 8:31 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: libcrypto/BIO: creating PEM in memory
> > >
> > >
> > > Hello,
> > >
> > > I would like to create PEM in memory, e. g. using libcrypto
> > > to generate
> > > a RSA key and have the resulting PEM as a simple char *.
> > >
> > > I tried to use BIO_s_mem to let the PEM routines write into memory:
> > >
> > > -----
> > > if ((out = BIO_new (BIO_s_mem ())) == NULL)
> > > return (FALSE);
> > >
> > > if (!PEM_write_bio_RSAPrivateKey (out,rsa,enc,NULL,0,NULL,passout))
> > > return (FALSE);
> > >
> > > n = BIO_get_mem_ptr (out,&p);
> > > strncpy (pem,p,n);
> > > pem [n] = 0;
> > >
> > > printf (">>%s<<\n",pem);
> > > -----
I normally use BIO_gets to get chars from a BIO, and it's ok to exchange
data from PEM* routines with output only to BIO .
Another hints: it's better to do a BIO_reset(out) before using the
BIO...
Good Luck.
--
Dott. Sergio Rabellino
Technical Staff
Department of Computer Science
University of Torino (Italy)
Member of the Internet Society
http://www.di.unito.it/~rabser
Tel. +39-0116706701
Fax. +39-011751603
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]