01e1152003-03-12Niels Möller AC_INIT(nettle.cmod)
bfd43f2003-03-13Niels Möller AC_CONFIG_HEADER(nettle_config.h)
01e1152003-03-12Niels Möller  AC_SET_MAKE AC_MODULE_INIT()
3b73682004-02-27Henrik Grubbström (Grubba) if test "$with_nettle" = "no"; then
2c22ff2013-12-02Martin Nilsson  PIKE_FEATURE_WITHOUT(Nettle)
3b73682004-02-27Henrik Grubbström (Grubba) else
60c5a32014-10-15Martin Nilsson  dnl GMP is required and tested for in Gmp module. We just want LIBS dnl updated here. AC_CHECK_LIB(gmp, main)
c317452007-03-20Henrik Grubbström (Grubba)  AC_MSG_CHECKING(CryptAcquireContext in -ladvapi32) AC_CACHE_VAL(pike_cv_nettle_advapi32_CryptAcquireContext, [ OLDLIBS="$LIBS" LIBS="-ladvapi32 $LIBS" AC_TRY_LINK([#ifndef _WIN32_WINNT #define _WIN32_WINNT 0x0400 #endif #include <windows.h> #include <wincrypt.h> ],[CryptAcquireContext(0,0,0,0,0);], [pike_cv_nettle_advapi32_CryptAcquireContext=yes], [pike_cv_nettle_advapi32_CryptAcquireContext=no]) LIBS="$OLDLIBS" ]) AC_MSG_RESULT($pike_cv_nettle_advapi32_CryptAcquireContext) if test x"$pike_cv_nettle_advapi32_CryptAcquireContext" = xyes; then LIBS="-ladvapi32 $LIBS" fi
3b73682004-02-27Henrik Grubbström (Grubba)  AC_CHECK_LIB(nettle, nettle_md5_init) AC_CHECK_LIB(nettle, md5_init)
14150e2014-01-13Per Hedbor  AC_CHECK_LIB(hogweed, nettle_rsa_generate_keypair) if test "x$ac_cv_lib_hogweed_nettle_rsa_generate_keypair" = "xyes" ; then AC_MSG_CHECKING([if nettle_*_generate_keypair takes qbits]) AC_CACHE_VAL(pike_cv_nettle_hogweed_keypair_args, [ pike_cv_nettle_hogweed_keypair_args=no AC_TRY_COMPILE([ #include <nettle/dsa.h> #include <nettle/rsa.h> ], [ struct dsa_public_key pub; struct dsa_private_key key; nettle_dsa_generate_keypair(&pub, &key, 0, 0, 0, 0, 2048, 384); ], [ pike_cv_nettle_hogweed_keypair_args=yes ]) ]) AC_MSG_RESULT($pike_cv_nettle_hogweed_keypair_args); if test "x$pike_cv_nettle_hogweed_keypair_args" = "xyes"; then AC_DEFINE(HAVE_DSA_QBITS_KEYPAIR_ARG, [], [Define if generate_dsa_keypair takes the qbits argument]) fi
60c5a32014-10-15Martin Nilsson  fi
01e1152003-03-12Niels Möller 
6d47f92016-09-23Henrik Grubbström (Grubba)  # NB: Some versions of RedHat have censored the weaker curves # (secp_192r1 and secp_224r1 (cf [LysLysKOM 21863021])), and # there are no identifying macros, so we need to probe for them. define(PIKE_CHECK_ECC_CURVE, [ AC_MSG_CHECKING(if curve $1 is available) AC_CACHE_VAL(pike_cv_have_curve_$1, [ AC_TRY_LINK([#include <nettle/ecc-curve.h>], [ struct ecc_curve *c = &$1; ], [ pike_cv_have_curve_$1=yes ], [ pike_cv_have_curve_$1=no ]) ]) AC_MSG_RESULT($pike_cv_have_curve_$1); if test "x$pike_cv_have_curve_$1" = "xyes"; then AC_DEFINE(translit(HAVE_CURVE_$1,[a-z],[A-Z]), 1, [Define if your libnettle has the curve $1.]) fi ])
13f8312016-10-19Martin Nilsson  AC_ARG_WITH(weak-curves, [ --with-weak-curves Include SECP192R1 and SECP224R1, frequently removed from Nettle binary dists ], [weak_curves=yes], []) if test "x$weak_curves" = "xyes" ; then PIKE_CHECK_ECC_CURVE(nettle_secp_192r1) PIKE_CHECK_ECC_CURVE(nettle_secp_224r1) fi
6d47f92016-09-23Henrik Grubbström (Grubba)  PIKE_CHECK_ECC_CURVE(nettle_secp_256r1) PIKE_CHECK_ECC_CURVE(nettle_secp_384r1) PIKE_CHECK_ECC_CURVE(nettle_secp_521r1)
3b73682004-02-27Henrik Grubbström (Grubba)  AC_SUBST(IDEA_OBJ)
c4fce42004-02-26Martin Nilsson 
3b73682004-02-27Henrik Grubbström (Grubba)  if test "x$ac_cv_lib_nettle_nettle_md5_init" = "xyes" -o \ "x$ac_cv_lib_nettle_md5_init" = "xyes"; then PIKE_FEATURE_OK(Nettle)
fe0ca62004-02-26Henrik Grubbström (Grubba) 
59c7d82014-04-06Martin Nilsson  # md4 is available in Nettle 1.8 and later. # arctwo is available in Nettle 1.11 and later. # ctr is available in Nettle 1.13 and later.
650f102011-12-23Henrik Grubbström (Grubba)  # camellia is available in Nettle 2.1 and later.
59c7d82014-04-06Martin Nilsson  # gcm is available in Nettle 2.2 and later. # ripemd160 is available in Nettle 2.3 and later.
9ce28d2014-06-09Henrik Grubbström (Grubba)  # sha3 and gosthash94 are available in Nettle 2.6 and later. # chacha, poly1305 and eax are available in Nettle 3.0 and later. AC_CHECK_HEADERS(nettle/md4.h \ nettle/arctwo.h \ nettle/ctr.h \ nettle/camellia.h \ nettle/gcm.h \ nettle/ripemd160.h \ nettle/sha3.h nettle/gosthash94.h \ nettle/chacha.h nettle/chacha-poly1305.h \ nettle/poly1305.h nettle/eax.h \ nettle/dsa.h nettle/umac.h nettle/ecdsa.h \
b5aab52016-12-05Martin Nilsson  nettle/version.h \
e7c1df2015-10-29Henrik Grubbström (Grubba)  ) # Check that the libraries match. # # Note that there can be false positives in the test above # when multiple versions of Nettle are installed concurrently. AC_CHECK_FUNCS(nettle_md4_init \ nettle_arctwo_encrypt \ nettle_ctr_crypt \ nettle_camellia128_crypt \ nettle_gcm_encrypt \ nettle_ripemd160_init \ nettle_sha3_256_init nettle_gosthash94_init \ nettle_chacha_crypt nettle_chacha_poly1305_encrypt \ nettle_poly1305_digest nettle_eax_encrypt \ nettle_dsa_sign nettle_umac128_digest nettle_ecdsa_sign \
b5aab52016-12-05Martin Nilsson  nettle_version_major \
e7c1df2015-10-29Henrik Grubbström (Grubba)  )
fe0ca62004-02-26Henrik Grubbström (Grubba) 
3b73682004-02-27Henrik Grubbström (Grubba)  AC_MSG_CHECKING([for idea.c]) # Have the patent-encumbered idea files been purged? if test -f "$srcdir/idea.c" ; then
fe0ca62004-02-26Henrik Grubbström (Grubba)  AC_MSG_RESULT([found]) AC_DEFINE([WITH_IDEA], 1, [idea.c available])
c4fce42004-02-26Martin Nilsson  IDEA_OBJ=idea.o
3b73682004-02-27Henrik Grubbström (Grubba)  else
c4fce42004-02-26Martin Nilsson  AC_MSG_RESULT([no]) IDEA_OBJ=""
3b73682004-02-27Henrik Grubbström (Grubba)  fi
776b502009-07-02Henrik Grubbström (Grubba) 
1cfe7f2014-04-17Henrik Grubbström (Grubba)  # These may have been purged from the Nettle lib to avoid GPL
776b502009-07-02Henrik Grubbström (Grubba)  # contamination. AC_CHECK_FUNCS(nettle_blowfish_decrypt nettle_serpent_decrypt) # This is the recomended interface in Nettle 2.0. AC_CHECK_FUNCS(nettle_yarrow256_slow_reseed)
1cfe7f2014-04-17Henrik Grubbström (Grubba)  # These weren't present in old Nettles.
c514492015-04-15Henrik Grubbström (Grubba)  AC_CHECK_FUNCS(nettle_salsa20_crypt nettle_sha224_init \ memxor3 nettle_memxor3)
df35cc2013-11-01Henrik Grubbström (Grubba) 
4df9fb2009-07-02Henrik Grubbström (Grubba)  AC_MSG_CHECKING([whether nettle_crypt_func is a pointer type]) AC_CACHE_VAL(pike_cv_nettle_crypt_func_is_pointer, [ pike_cv_nettle_crypt_func_is_pointer=no AC_TRY_COMPILE([
61d4242009-07-02Henrik Grubbström (Grubba) /* Note: Old Nettles had the nettle_crypt_func typedef directly * in <nettle/nettle-meta.h> while more modern have it in * <nettle/nettle-types.h>. Since <nettle/nettle-meta.h> * pulls in <nettle/nettle-types.h> it should be sufficient. */ #include <nettle/nettle-meta.h>
4df9fb2009-07-02Henrik Grubbström (Grubba)  ], [ nettle_crypt_func foo = (nettle_crypt_func)(void *)0; return (int)foo; ], [ pike_cv_nettle_crypt_func_is_pointer=yes ]) ]) AC_MSG_RESULT($pike_cv_nettle_crypt_func_is_pointer); if test "x$pike_cv_nettle_crypt_func_is_pointer" = "xyes"; then AC_DEFINE(HAVE_NETTLE_CRYPT_FUNC_IS_POINTER) fi
3b73682004-02-27Henrik Grubbström (Grubba)  else
b5ab692013-06-11Martin Nilsson  AC_ERROR([Cannot compile --with-nettle without the Nettle library.
ce23652004-10-05Martin Stjernholm It is highly recommended that you install a working Nettle library on your system as that will add features to Pike required by many applications. These features include ciphers, hash algorithms and random generators. If you know that you do not need cryptographic functions, you can re-run configure with the option --without-nettle instead. Nettle is available at http://www.lysator.liu.se/~nisse/nettle/.
3b73682004-02-27Henrik Grubbström (Grubba)  ]) PIKE_FEATURE_NODEP(Nettle) fi
c20d152004-02-06Niels Möller fi
01e1152003-03-12Niels Möller AC_OUTPUT(Makefile,echo FOO >stamp-h )