[EMAIL PROTECTED] wrote:
> 
> Hi all,
> 
> I am trying to generate an RSA keys pair and extract it to an (RSA *) which will
> reprensent the public key and another (RSA *) for the private key part.
> 
> I am doing (based on demos/eay/loadrsa.c)
> 
> RSA *rsa,*pub_rsa,*priv_rsa;
> int len;
> unsigned char buf[1024],*p;
> rsa=RSA_generate_key(512,RSA_F4,callback,(char *)stdout);
> p=buf;
> 
> then I would like to go in one step to have the *pub_rsa and *priv_rsa
> initialized...
> ie :
>  pub_rsa = RSA_SOMETHINGPUBLIC(rsa);
>  priv_rsa = RSA_SOMETHINGPRIVATE(rsa);
> 
> in demos/eay/loadrsa.c you can get pub_rsa and priv_rsa by transforming into der
> and next into rsa....but in my case I would do that in one step.
> 

Firstly you may well not need to do that. 

RSA_generate_key() generates an RSA private key.

An RSA private key can be used as a public key.

If you really want just the public components from a private key then:

rsa_pub = RSAPublicKey_dup(key);

will do the trick.

Steve.
-- 
Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED] 
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the   OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to