How to set "e" in RSA structure ?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to set "e" in RSA structure ?

Swamy J-S

Recently i upgraded openssl from 1.0.2 to 1.1.0. As RSA structure is opaque in new opnessl i made some modifications in my code as follows :

 

Old Code

RSA* rsa = EVP_PKEY_get1_RSA(PKey);

if(NULL != rsa)

{

if(!BN_set_word(rsa->e, 65537) || !EVP_PKEY_set1_RSA(PKey, rsa))

--------------------------------------------------------------------------------------------------

New Code

RSA* rsa = EVP_PKEY_get1_RSA(PKey);

BIGNUM *e_new = BN_new();

if(NULL != rsa)

{

if(!BN_set_word(e_new, 65537) || !EVP_PKEY_set1_RSA(PKey, rsa))

 

But Now "e" variable is not set in 'rsa', So how to set "e" inside rsa? Pls suggest me corresponding API

 

Thanks and Regards,

SWAMY J S

 

Reply | Threaded
Open this post in threaded view
|

Re: How to set "e" in RSA structure ?

Richard Levitte - VMS Whacker-2
RSA_set0_key() is the function you should use.

For more information, do 'man RSA_set0_key', or have a look here:

https://www.openssl.org/docs/man1.1.0/man3/RSA_set0_key.html

Cheers,
Richard

On Wed, 10 Jul 2019 11:51:01 +0200,
Swamy J-S wrote:

>
>
> Recently i upgraded openssl from 1.0.2 to 1.1.0. As RSA structure is opaque in new opnessl i made
> some modifications in my code as follows :
>
> Old Code
>
> RSA* rsa = EVP_PKEY_get1_RSA(PKey);
>
> if(NULL != rsa)
>
> {
>
> if(!BN_set_word(rsa->e, 65537) || !EVP_PKEY_set1_RSA(PKey, rsa))
>
> --------------------------------------------------------------------------------------------------
>
> New Code
>
> RSA* rsa = EVP_PKEY_get1_RSA(PKey);
>
> BIGNUM *e_new = BN_new();
>
> if(NULL != rsa)
>
> {
>
> if(!BN_set_word(e_new, 65537) || !EVP_PKEY_set1_RSA(PKey, rsa))
>
> But Now "e" variable is not set in 'rsa', So how to set "e" inside rsa? Pls suggest me
> corresponding API
>
> Thanks and Regards,
>
> SWAMY J S
>
>
--
Richard Levitte         [hidden email]
OpenSSL Project         http://www.openssl.org/~levitte/