Error: "invalid use of incomplete type ‘RSA {aka struct rsa_st}" in OpenSSL 1.1.0

Shachar Shemesh

I have old code that was written to link against an old version of openssl. Part of this code loads a key from a PEM file, and tries to understand whether this key is a private or public key, by using the following code:

if( (prv->p==0 || prv->q==0) ) {
    // This is not a private key!
    throw error("No private key for decryption");
}

With the latest version of openssl, this (justifiably) doesn't compile:

crypto.cpp: In function ‘key* decrypt_header(file_t, RSA*)’:
crypto.cpp:158:13: error: invalid use of incomplete type ‘RSA {aka struct rsa_st}’
     if( (prv->p==0 || prv->q==0) ) {
             ^~

I understand that direct access to the struct's private members was replaced with a function, but I am having a hard time figuring out which function that is.

jww
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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Ruby OpenSSL nested asn1 error

From Dev

OpenSSL undefined symbol: EVP_mdc2, version OPENSSL_1_1_0

From Dev

Executed 0 of 1 (skipped 1) ERROR in Jasmine

From Dev

Why do OpenSSL crypto functions return 1 on success, 0 on failure?

From Dev

PHP syntax error when using 1===1 but not when 1===0

From Dev

simplehtmldom - SSL operation failed with code 1. OpenSSL Error messages

From Dev

fwrite(): SSL operation failed with code 1. OpenSSL Error messages:error:1420C0CF:SSL routines:ssl_write_internal:protocol is shutdown

From Dev

file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000126:SSL routines::unexpected eof while reading

From Dev

stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00010B:SSL routines::wrong version number

From Dev

Assertion Error: 1 == 0 for MongoDB deleteOne Command

From Dev

"takes 0 positional arguments but 1 was given" error

From Dev

Gradle build error 1,0

From Dev

The volume provided is outside the range [0, 1] error

From Dev

Error in 1:x : argument of length 0

From Dev

Why ++[] throws an error but ++[[]][0] produces 1?

From Dev

boolean values, run time error if not 0 or 1

From Dev

Fortran "Error: Incompatible ranks 0 and 1 in assignment"

From Dev

invalid initializer error for argv[0] and argv[1]?

From Dev

error value: Expecting value: line 1 column 1 (char 0)

From Dev

JSONDecodeError: Expecting value: line 1 column 1 (char 0) error

From Dev

Error in `filter()`: Input `..1` must be of size 4 or 1, not size 0

From Dev

Meaning of [ "${1:0:1}" = '-' ]

From Dev

Is (0*1*)* equal to (0 | 1)*?

From Dev

SHA1 Mismatches openssl

From Dev

Error running '__rvm_make -j 1' during rvm Ruby installation | openssl error

From Dev

openssl/curl error: SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

From Dev

Mediaplayer error (-38,0) and error (1,-1010)

From Dev

Json to Dataframe: error: error in 1:nrow(test) : argument of length 0

From Dev

Error using sklearn and linear regression: shapes (1,16) and (1,1) not aligned: 16 (dim 1) != 1 (dim 0)

Related Related

  1. 1

    Ruby OpenSSL nested asn1 error

  2. 2

    OpenSSL undefined symbol: EVP_mdc2, version OPENSSL_1_1_0

  3. 3

    Executed 0 of 1 (skipped 1) ERROR in Jasmine

  4. 4

    Why do OpenSSL crypto functions return 1 on success, 0 on failure?

  5. 5

    PHP syntax error when using 1===1 but not when 1===0

  6. 6

    simplehtmldom - SSL operation failed with code 1. OpenSSL Error messages

  7. 7

    fwrite(): SSL operation failed with code 1. OpenSSL Error messages:error:1420C0CF:SSL routines:ssl_write_internal:protocol is shutdown

  8. 8

    file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:0A000126:SSL routines::unexpected eof while reading

  9. 9

    stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:0A00010B:SSL routines::wrong version number

  10. 10

    Assertion Error: 1 == 0 for MongoDB deleteOne Command

  11. 11

    "takes 0 positional arguments but 1 was given" error

  12. 12

    Gradle build error 1,0

  13. 13

    The volume provided is outside the range [0, 1] error

  14. 14

    Error in 1:x : argument of length 0

  15. 15

    Why ++[] throws an error but ++[[]][0] produces 1?

  16. 16

    boolean values, run time error if not 0 or 1

  17. 17

    Fortran "Error: Incompatible ranks 0 and 1 in assignment"

  18. 18

    invalid initializer error for argv[0] and argv[1]?

  19. 19

    error value: Expecting value: line 1 column 1 (char 0)

  20. 20

    JSONDecodeError: Expecting value: line 1 column 1 (char 0) error

  21. 21

    Error in `filter()`: Input `..1` must be of size 4 or 1, not size 0

  22. 22

    Meaning of [ "${1:0:1}" = '-' ]

  23. 23

    Is (0*1*)* equal to (0 | 1)*?

  24. 24

    SHA1 Mismatches openssl

  25. 25

    Error running '__rvm_make -j 1' during rvm Ruby installation | openssl error

  26. 26

    openssl/curl error: SSL23_GET_SERVER_HELLO:tlsv1 alert internal error

  27. 27

    Mediaplayer error (-38,0) and error (1,-1010)

  28. 28

    Json to Dataframe: error: error in 1:nrow(test) : argument of length 0

  29. 29

    Error using sklearn and linear regression: shapes (1,16) and (1,1) not aligned: 16 (dim 1) != 1 (dim 0)

HotTag

Archive