crypto.cpp:158:13: error: invalid use of incomplete type ‘RSA {aka struct rsa_st}’
if( (prv->p==0 || prv->q==0) ) {
^~
As you are aware, OpenSSL 1.1.0 changed the visibility of a lot of struct members. You can no longer access the members directly. Instead, you have to use getter and setter functions.
Try RSA_get0_factors
. The get0
means the reference counts are not incremented. Do not BN_free
them.
void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q);
If the code supports multiple versions of OpenSSL, then you will need a guard because RSA_get0_factors
is for OpenSSL 1.1.0 and above. Maybe something like the following. Also see OPENSSL_VERSION_NUMBER
man page.
#include <openssl/opensslv.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
/* OpenSSL 1.0.2 and below (old code) */
#else
/* OpenSSL 1.1.0 and above (new code) */
#endif