skip to Main Content

I was experimenting with some ~2005 C code (using OpenSSL 0.9.8, I think) and I tried make-ing it with OpenSSL 3.0.2 on Ubuntu 22.04.

Minimum example:

#include <openssl/bn.h>

struct fraction
{
    BIGNUM numerator;
    BIGNUM denominator;
}

Expected: everything builds, just as intended.

Actual: complier complains about incomplete type declaration for both fields.

Why does this happen? Is this not a valid declaration? Or is it something else?

2

Answers


  1. Chosen as BEST ANSWER

    From dbush's answer:

    Starting from OpenSSL version 1.1.0, BIGNUM was made a opaque type, which means that it can't be created directly from user code.

    Pointers to the type are needed. So instead of this:

    #include <openssl/bn.h>
    
    struct fraction
    {
        // Direct access
        BIGNUM numerator;
        BIGNUM denominator;
    }
    

    You would use this:

    #include <openssl/bn.h>
    
    struct fraction
    {
        // Pointer access
        BIGNUM *numerator;
        BIGNUM *denominator;
    }
    

  2. Later versions of OpenSSL made several types opaque, including BIGNUM, which means you can’t instantiate them directly in user code. The BIGNUM type in particular became an opaque type starting with version 1.1.0.

    You would instead need to use pointers:

    struct fraction
    {
        BIGNUM *numerator;
        BIGNUM *denominator;
    };
    

    And use the appropriate functions to create and destroy them, as well as use the relevant accessor functions to access the members.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search