Missing definitions in Headerfile dh.h (openssl 1.1.0f)

Viewed 1962

For some reason I can't find the definition+members of "struct dh_st". It is supposed to be in openssl/dh.h, but that is not the case. However in a earlier version of openssl (openssl-1.0/openssl/dh.h), there is an definition (I need to use 1.1.0f though).

Code-Snippet of the relevant part:

DH *dh_obj;
// [...]
BIGNUM *temp_p = dh_obj->p; // p is not accessible/visible here!
// [...]

Error message during compilation in gcc 7.1.1:

gcc -o dh dh.c -L/usr/lib -lssl -lcrypto && ./dh

dh.c: In function ‘main’: dh.c:57:26: error: dereferencing pointer to incomplete type ‘DH {aka struct dh_st}’ BIGNUM *temp_p = dh_obj->p;

And this is how the struct looks like (in openssl-1.0 !! not in my current version, because there is no such definition)

struct dh_st {
/*
 * This first argument is used to pick up errors when a DH is passed
 * instead of a EVP_PKEY
 */
    int pad;
    int version;
    BIGNUM *p;
    BIGNUM *g;
    long length;                /* optional */
    BIGNUM *pub_key;            /* g^x % p */
    BIGNUM *priv_key;           /* x */
    int flags;
    BN_MONT_CTX *method_mont_p;
    /* Place holders if we want to do X9.42 DH */
    BIGNUM *q;
    BIGNUM *j;
    unsigned char *seed;
    int seedlen;
    BIGNUM *counter;
    int references;
    CRYPTO_EX_DATA ex_data;
    const DH_METHOD *meth;
    ENGINE *engine;

};

Any Help appreciated!

2 Answers

Any of the values p, q, g, priv_key, and pub_key can also be retrieved separately from DH* structure by the corresponding function DH_get0_p(), DH_get0_q(), DH_get0_g(), DH_get0_priv_key(), and DH_get0_pub_key(), respectively

Prototype:

const BIGNUM *DH_get0_p(const DH *dh);


const BIGNUM *DH_get0_q(const DH *dh);


const BIGNUM *DH_get0_g(const DH *dh);

const BIGNUM *DH_get0_priv_key(const DH *dh);


const BIGNUM *DH_get0_pub_key(const DH *dh);
Related