Hi Thijs,
try this:

int nPrivateKeyLength = i2d_RSAPrivateKey(pRSA, 0);     // You receive length in
bytes.
char* pcPrivateKey = new char[nPrivateKeyLength];       // Allocate memory.
i2d_RSAPrivateKey(pRSA, &pcPrivateKey );                        // Store Private key 
into memory.

Now you may write pcPrivateKey to the file (fwrite or something else).

Same approach you may use for public key.

Regards,
Yuriy Stul, Tashilon Core Technology Manager

[mailto:[EMAIL PROTECTED]]
[http://www.tashilon.com]

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: Thursday, December 07, 2000 14:23
> To: [EMAIL PROTECTED]
> Subject: ARGH: Help me PLEASE :(
>
>
>
> Hi,
>
> I hope somebody will help me.
> For the last two weeks i am trying to write RSA keys to disk.
> I want two files, one with the private Key and one with the
> Public key (this one
> is distributed).
> For some unknown reason nothing I have tried will work. I tried
> to write the
> files with and without BIO and FP, I have tried to convert from
> ASN to DER and
> then write to disk. But always something fails, then the write
> succeeds but the
> readback fails, then the write fails en the readback succeeds.
>
> Can anybody please construct a very simple but effective piece of
> source which
> writes an RSA keypair into two files and reads them back in one
> RSA structure ??
> I don't care in which way it is done, if only it works.
>
> Thanks you very much. I am supposed to have my application done
> on a deadline
> but in the way this is going I will netver get it done on time.
>
>
> Thanks,
>
> Thijs.
>
> ______________________________________________________________________
> OpenSSL Project                                 http://www.openssl.org
> User Support Mailing List                    [EMAIL PROTECTED]
> Automated List Manager                           [EMAIL PROTECTED]
>

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

Reply via email to