>>"Hellan,Kim KHE" wrote:
>> 
>> I need to duplicate an EVP_PKEY. Is that possible?
>> There is an X509_dup(), but there is no EVP_PKEY_dup().
>> 

>Ooops, I forgot about that.

I guess this means that this function will be in later versions of OpenSSL
:-)

>Alternatively you do something like...

>dupkey = EVP_PKEY_new();

>switch(key->type)
>{
>       case EVP_PKEY_RSA:
>       rsa = EVP_PKEY_get1_RSA(key);
>       duprsa = RSA_dup(rsa);
>       RSA_free(rsa);
>       EVP_PKEY_set1_RSA(dupkey, duprsa);
>       RSA_free(duprsa);
>       break;
>       ....
>}

>Dr Stephen N. Henson.   http://www.drh-consultancy.demon.co.uk/

Well... actually there is no RSA_dup() either :-)...... but the following
should works as well:
....
EVP_PKEY* pDupKey = EVP_PKEY_new();
RSA* pRSA = EVP_PKEY_get1_RSA(pKey);
EVP_PKEY_set1_RSA(pDupKey, pRSA);
RSA_free(pRSA);
return(pDupKey);

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

Reply via email to