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.