Hi all,
Just if anybody needs it, this is working:
RSA *rsa = NULL;
const EVP_CIPHER *enc=NULL;
unsigned long f4=RSA_F4;
char outfile[20];
char passout[10];
BIO *bio = NULL;
int num;
num = 1024;
memcpy(&passout[0],"teste",5);
passout[5] = '\0';
memcpy(&outfile[0],"teste_kpr.pem",13);
passout[13] = '\0';
BIGNUM *bn = BN_new();
bio = BIO_new(BIO_s_file());
BIO_write_filename(bio,outfile);
rsa = RSA_new();
if (rsa == NULL)
return;
BN_set_word(bn, f4);
RSA_generate_key_ex(rsa, num, bn, NULL);
PW_CB_DATA cb_data;
cb_data.password = passout;
cb_data.prompt_info = outfile;
PEM_write_bio_RSAPrivateKey(bio,rsa,enc,NULL,0,NULL,&cb_data);
if (bn != NULL)
BN_free(bn);
if (rsa != NULL)
RSA_free(rsa);
if (bio != NULL)
BIO_free_all(bio);
The code is for testing, I recommend whom uses it to add some consistence,
as I will.
:)
Leonardo
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [email protected]