Hi, I'm a beginner programmer and I have been dropped into a big
cryptographic project. My boss went away, and told me what to do still he
comes back.
I have to do the following things in C:

-generate an RSA key pair
-write it out in a file in DER or PEM format

I tryed the following code:

#include <stdio.h>
#include <stdlib.h>
#include <openssl/rsa.h>

void main()
{
     RSA *rsa;
     FILE *file;
     int modulus_size = 1024;
     int public_exponent = 65535;
     RAND_screen();
     rsa = RSA_new();
     rsa = RSA_generate_key(modulus_size, public_exponent, NULL,NULL);
     file=fopen("out.rsa","w");
     PEM_write_RSAPrivateKey(file,rsa,NULL,NULL,0,NULL,NULL);
     fclose(file);
}

But I get a nice error box from Windows with the following: This program
has performed an illegal operation, and will be closed....

The problem must be with the PEM_write_RSAPrivateKey.

What should I do ?
Or if you can't tell how to write in DER format, then just simply tell how
works the RSA_print_fp(..) function because I've got the same error message
with it.

Thank you

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

Reply via email to