invalid use of incomplete type ‘RSA {aka struct rsa_st}’

If you are compiling code that use old openssl lib(such as openssl 1.0.2) with the latest openssl lib such as openssl 1.1.0, you will meet this error:

invalid use of incomplete type ‘RSA {aka struct rsa_st}’

In old openssl lib, you can set the modulus, public exponent, and private exponent of a RSA structure as follows:

 BIGNUM *bnn, *bne, *bnd;
 bnn = BN_new();
 bne = BN_new();
 bnd = BN_new();

 BN_hex2bn(&bnn, MODULUS);
 BN_set_word(bne, PUBLIC_EXPONENT);
 BN_hex2bn(&bnd, PRIVATE_EXPONENT);            

RSA *r = RSA_new();
r->n = bnn;
r->e = bne;
r->d = bnd;

However, after porting to the new openssl lib, you should set the n,e,d of a RSA struct using the RSA_set0_key function:

RSA_set0_key(r,bnn,bne,bnd);

Similarly,  you should get the n,e,d components of RSA using RSA_get0_key.

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply