Skip to content

[libcmb] GCC error for use of void BN_zero() with OpenSSL #3

@zmughal

Description

@zmughal

I get the following error with gcc 12.

gcc -fPIC -Wall -I. -I/usr/local/include -DHAVE_CONFIG_H -c cmb.c -o cmb.o
cmb.c: In function ‘cmb_count_bn’:
cmb.c:854:13: error: invalid use of void expression
  854 |         if (!BN_zero(count))
      |             ^
cmb.c: In function ‘cmb_bn’:
cmb.c:1032:21: error: invalid use of void expression
 1032 |                 if (!BN_zero(seq))
      |                     ^
make: *** [GNUmakefile:39: cmb.o] Error 1

Per the OpenSSL docs:

void BN_zero(BIGNUM *a);

...
In OpenSSL 0.9.8, BN_zero() was changed to not return a value; previous versions returned an int.

This can be fixed by enabling the deprecated API using OPENSSL_API_COMPAT, but this is incompatible with LibreSSL where the deprecated API is still available under the name BN_zero (source):

int
BN_zero(BIGNUM *a);

One approach is to switch to the new API BN_zero_ex() which appeared in OpenSSL 0.9.8. Another is to use BN_set_word as here:

#  define BN_zero(a)      (BN_set_word((a),0))

which is compatible with older versions of OpenSSL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions