configure: prefer gnutls over nss and tomcrypt for hashing

Reorder the tests in the configure script to prefer gnutls over nss and
tomcrypt as its support includes AES-CMAC.
This commit is contained in:
Miroslav Lichvar 2023-09-12 10:36:23 +02:00
parent 558931524d
commit f2d7baa94f
3 changed files with 30 additions and 30 deletions

46
configure vendored
View file

@ -111,10 +111,10 @@ For better control, use the options below.
--without-editline Don't use editline even if it is available --without-editline Don't use editline even if it is available
--disable-sechash Disable support for hashes other than MD5 --disable-sechash Disable support for hashes other than MD5
--without-nettle Don't use nettle even if it is available --without-nettle Don't use nettle even if it is available
--without-gnutls Don't use gnutls even if it is available
--without-nss Don't use NSS even if it is available --without-nss Don't use NSS even if it is available
--without-tomcrypt Don't use libtomcrypt even if it is available --without-tomcrypt Don't use libtomcrypt even if it is available
--disable-nts Disable NTS support --disable-nts Disable NTS support
--without-gnutls Don't use gnutls even if it is available
--disable-cmdmon Disable command and monitoring support --disable-cmdmon Disable command and monitoring support
--disable-ntp Disable NTP support --disable-ntp Disable NTP support
--disable-refclock Disable reference clock support --disable-refclock Disable reference clock support
@ -926,6 +926,28 @@ if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ $try_nettle = "1" ];
fi fi
fi fi
if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ $try_gnutls = "1" ]; then
test_cflags="`pkg_config --cflags gnutls`"
test_link="`pkg_config --libs gnutls`"
if test_code 'gnutls' 'gnutls/crypto.h' \
"$test_cflags" "$test_link" '
return gnutls_hash((void *)1, (void *)2, 1);'
then
HASH_OBJ="hash_gnutls.o"
HASH_LINK="$test_link"
MYCPPFLAGS="$MYCPPFLAGS $test_cflags"
add_def FEAT_SECHASH
if test_code 'CMAC in gnutls' 'gnutls/crypto.h' "$test_cflags" "$test_link" \
'return gnutls_hmac_init((void *)1, GNUTLS_MAC_AES_CMAC_128, (void *)2, 0);'
then
add_def HAVE_CMAC
EXTRA_OBJECTS="$EXTRA_OBJECTS cmac_gnutls.o"
EXTRA_CLI_OBJECTS="$EXTRA_CLI_OBJECTS cmac_gnutls.o"
fi
fi
fi
if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ $try_nss = "1" ]; then if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ $try_nss = "1" ]; then
test_cflags="`pkg_config --cflags nss`" test_cflags="`pkg_config --cflags nss`"
test_link="`pkg_config --libs-only-L nss` -lfreebl3 -lnssutil3" test_link="`pkg_config --libs-only-L nss` -lfreebl3 -lnssutil3"
@ -951,28 +973,6 @@ if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ $try_tomcrypt = "1" ]
fi fi
fi fi
if [ $feat_sechash = "1" ] && [ "x$HASH_LINK" = "x" ] && [ $try_gnutls = "1" ]; then
test_cflags="`pkg_config --cflags gnutls`"
test_link="`pkg_config --libs gnutls`"
if test_code 'gnutls' 'gnutls/crypto.h' \
"$test_cflags" "$test_link" '
return gnutls_hash((void *)1, (void *)2, 1);'
then
HASH_OBJ="hash_gnutls.o"
HASH_LINK="$test_link"
MYCPPFLAGS="$MYCPPFLAGS $test_cflags"
add_def FEAT_SECHASH
if test_code 'CMAC in gnutls' 'gnutls/crypto.h' "$test_cflags" "$test_link" \
'return gnutls_hmac_init((void *)1, GNUTLS_MAC_AES_CMAC_128, (void *)2, 0);'
then
add_def HAVE_CMAC
EXTRA_OBJECTS="$EXTRA_OBJECTS cmac_gnutls.o"
EXTRA_CLI_OBJECTS="$EXTRA_CLI_OBJECTS cmac_gnutls.o"
fi
fi
fi
EXTRA_OBJECTS="$EXTRA_OBJECTS $HASH_OBJ" EXTRA_OBJECTS="$EXTRA_OBJECTS $HASH_OBJ"
EXTRA_CLI_OBJECTS="$EXTRA_CLI_OBJECTS $HASH_OBJ" EXTRA_CLI_OBJECTS="$EXTRA_CLI_OBJECTS $HASH_OBJ"
LIBS="$LIBS $HASH_LINK" LIBS="$LIBS $HASH_LINK"

View file

@ -7,9 +7,9 @@ for opts in \
"--host-system=NetBSD" \ "--host-system=NetBSD" \
"--host-system=FreeBSD" \ "--host-system=FreeBSD" \
"--without-nettle" \ "--without-nettle" \
"--without-nettle --without-nss" \ "--without-nettle --without-gnutls" \
"--without-nettle --without-nss --without-tomcrypt" \ "--without-nettle --without-gnutls --without-nss" \
"--without-nettle --without-nss --without-tomcrypt --without-gnutls" "--without-nettle --without-gnutls --without-nss --without-tomcrypt"
do do
./configure $opts ./configure $opts
scan-build make "$@" || exit 1 scan-build make "$@" || exit 1

View file

@ -25,13 +25,13 @@ touch Makefile
for extra_config_opts in \ for extra_config_opts in \
"--all-privops" \ "--all-privops" \
"--disable-ipv6" \ "--disable-ipv6" \
"--disable-nts" \
"--disable-scfilter" \ "--disable-scfilter" \
"--without-aes-gcm-siv" \ "--without-aes-gcm-siv" \
"--without-gnutls" \
"--without-nettle" \ "--without-nettle" \
"--without-nettle --without-nss" \ "--without-nettle --without-gnutls" \
"--without-nettle --without-nss --without-tomcrypt" \ "--without-nettle --without-gnutls --without-nss" \
"--without-nettle --without-nss --without-tomcrypt --without-gnutls"; \ "--without-nettle --without-gnutls --without-nss --without-tomcrypt"; \
do do
for arch_opts in "-m32" ""; do for arch_opts in "-m32" ""; do
pushd test/simulation/clknetsim || exit 1 pushd test/simulation/clknetsim || exit 1