[openssl-users] lh_CONF_VALUE_new parameters?

Matěj Cepl mcepl at cepl.eu
Tue Apr 12 20:51:50 UTC 2016


Hi,

I am trying to make M2Crypto build on Windows again
(https://gitlab.com/m2crypto/m2crypto/merge_requests/26). I have
replaced by POSIX's poll by WSAPoll( I know about
https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ but we
don't play with the error values, which is a mistake, I know, so
we shouldn't be affected).

The second problem is that VC++ compiler crashes on problems
with CONF_VALUE. Originally M2Crypto had this
(https://gitlab.com/m2crypto/m2crypto/blob/master/SWIG/_x509.i#L514):

    #if OPENSSL_VERSION_NUMBER >= 0x10000000L
    LHASH_OF(CONF_VALUE)
    #else
    LHASH
    #endif
    *x509v3_lhash() {
        return lh_new(NULL, NULL); /* Should probably be lh_CONF_VALUE_new but won't compile. */
    }

Apparently, using lh_new(NULL, NULL) is not good enough for VC++
and it crashes on it
(https://ci.appveyor.com/project/mcepl/m2crypto-nngqn/build/job/e7q2ogndlje2x2h9)

After a deep dive into lhash(3) and some examples on github,
I have created this:

    /*
    typedef struct
            {
            char *section;
            char *name;
            char *value;
            } CONF_VALUE;

     */

    unsigned long CONF_VALUE_hash(const CONF_VALUE *v) {
        char *v_key, *hash_hex;

        v_key = strncat(v1->section, v1->name, 1024);
        v_key = strncat(v1_key, v1->value, 2048);

        return *(unsigned long *) SHA256(v_key, strlen(v_key), hash_hex);
    }
    static IMPLEMENT_LHASH_HASH_FN(CONF_VALUE_hash, const CONF_VALUE*);

    int CONF_VALUE_cmp(const CONF_VALUE *v1, const CONF_VALUE *v2) {
        char *v1_key, *v2_key;

        v1_key = strncat(v1->section, v1->name, 1024);
        v1_key = strncat(v1_key, v1->value, 2048);

        v2_key = strncat(v2->section, v2->name, 1024);
        v2_key = strncat(v2_key, v2->value, 2048);

        return strncmp(v1_key, v2_key, 2048);
    }
    static IMPLEMENT_LHASH_COMP_FN(CONF_VALUE_cmp, const CONF_VALUE*);

    #if OPENSSL_VERSION_NUMBER >= 0x10000000L
    LHASH_OF(CONF_VALUE)
    #else
    LHASH
    #endif
    *x509v3_lhash() {
        return lh_CONF_VALUE_new(CONF_VALUE_hash, CONF_VALUE_cmp);
    }

but gcc still fails to compile with error:

    SWIG/_x509.i:554: Error: Macro 'lh_CONF_VALUE_new' expects 
    no arguments

lh_CONF_VALUE_new with arguments is however exactly what I found 
on the Internet (and in crypt/conf/conf_api.c, which seems to be 
the only use of lh_CONF_VALUE_new in OpenSSL tree).

Using openssl-1.0.1e-56.el7.x86_64 on RHEL-7.

Could anybody enlighten me, how to make lh_CONF_VALUE_new 
working, please?

Thank you,

Matěj

--
https://matej.ceplovi.cz/blog/, Jabber: mcepl at ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB  25C3 E09F EF25 D964 84AC

You either die a hero or you live long enough to see yourself become the villain.
  -- Harvey Dent in The Dark Knight



More information about the openssl-users mailing list