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
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:
You would use this:
Later versions of OpenSSL made several types opaque, including
BIGNUM
, which means you can’t instantiate them directly in user code. TheBIGNUM
type in particular became an opaque type starting with version 1.1.0.You would instead need to use pointers:
And use the appropriate functions to create and destroy them, as well as use the relevant accessor functions to access the members.