>> But anyway.....
>> Do you have any suggestions, how to properly implement the RSA_dup()
>> function you suggested earlier, assuming that we are only talking
software
>> keys? 

>Well it depends on what you want to actually do. If you have an EVP_PKEY
>structure and you want to be able to pass it to two separate functions
>which will each individually call EVP_PKEY_free() the upping the
>reference count of the EVP_PKEY structure will work fine.

>There are two functions RSAPublicKey_dup() and RSAPrivateKey_dup() which
>will just dup the relevant parts of the RSA structure. Which you use
>depends on whether its a public or private key.

>Steve.

Thanks a lot!
I ended up with the following code, which seems to works fine:

EVP_PKEY* pDupKey = EVP_PKEY_new();
RSA* pRSA = EVP_PKEY_get1_RSA(pKey);
RSA* pRSADupKey;
if( eKeyType == eKEY_PUBLIC ) // Determine the type of the "source" EVP_PKEY
  pRSADupKey = RSAPublicKey_dup(pRSA);
else
  pRSADupKey = RSAPrivateKey_dup(pRSA);
RSA_free(pRSA);
EVP_PKEY_set1_RSA(pDupKey, pRSADupKey);
RSA_free(pRSADupKey);
return(pDupKey);

If you see any problems with this approach, please let me know.
Otherwise..... once again thank you for all your help!

Best regards

Kim Hellan
KMD / KMD-CA
http://www.kmd-ca.dk
Mailto:[EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to