AC_CHECK_FUNC([accept], , [LIBS=$oldLibs])
fi
AC_CHECK_FUNC([gethostbyname], ,[AC_CHECK_LIB(nsl, main, [LIBS="$LIBS -lnsl"])])
+dnl
+dnl ------ nettle
+nettle=default
+AC_SUBST([NETTLE_LIBS])
+AC_ARG_WITH([nettle], [ --with-nettle Nettle library], [nettle=$withval])
+if test "$nettle" != "no"; then
+ AC_MSG_CHECKING([for nettle])
+ if $pkgconfigpath --cflags nettle >/dev/null 2>&1 ; then
+ if $pkgconfigpath --atleast-version 2.0 nettle; then
+ AC_MSG_RESULT([yes])
+ CFLAGS="$CFLAGS `$pkgconfigpath --cflags nettle`"
+ NETTLE_LIBS="`$pkgconfigpath --libs nettle`"
+ libgcryptversion=2enable
+ AC_DEFINE([HAVE_NETTLE],[1],[Define to 1 if nettle is enabled])
+ else
+ AC_MSG_RESULT([no. Version 2.0 required])
+ if test "$nettle" != "default"; then
+ AC_MSG_ERROR([nettle libraries missing])
+ fi
+ fi
+ else
+ AC_MSG_RESULT([no])
+ if test "$nettle" != "default"; then
+ AC_MSG_ERROR([nettle libraries missing])
+ fi
+ fi
+fi
+dnl
+dnl
dnl ------ libgcrypt
AC_SUBST([GCRYPT_LIBS])
libgcryptpath=NONE
AC_ARG_WITH(libgcrypt, [ --with-libgcrypt=DIR use libgcrypt-config in DIR],[libgcryptpath=$withval])
-if test "$libgcryptpath" != "no"; then
+if test "$libgcryptpath" != "no" -a -z "$libgcryptversion"; then
if test "$libgcryptpath" = "NONE"; then
AC_PATH_PROG([libgcrypt],[libgcrypt-config],[NONE])
elif test -x $libgcryptpath/libgcrypt-config; then
fi
fi
fi
+dnl
+dnl
+dnl
dnl ------ GNU TLS
AC_SUBST([SSL_CFLAGS])
AC_SUBST([SSL_LIBS])
YAZCOMP_I = $(YAZCOMP) -d $(srcdir)/ill.tcl -i yaz -I$(top_srcdir)/include
AM_CPPFLAGS=-I$(top_srcdir)/include $(XML2_CFLAGS) $(SSL_CFLAGS)
-libyaz_la_LIBADD = $(SSL_LIBS) $(TCPD_LIBS) $(GCRYPT_LIBS) \
+libyaz_la_LIBADD = $(SSL_LIBS) $(TCPD_LIBS) $(NETTLE_LIBS) $(GCRYPT_LIBS) \
$(MEMCACHED_LIBS) $(HIREDIS_LIBS)
libyaz_server_la_LIBADD = libyaz.la
libyaz_icu_la_CPPFLAGS = $(AM_CPPFLAGS) $(ICU_CPPFLAGS) -I$(top_srcdir)/libstemmer_c/include
#if HAVE_GCRYPT_H
#include <gcrypt.h>
#endif
+#if HAVE_NETTLE
+#include <nettle/sha.h>
+#endif
int wrbuf_sha1_write(WRBUF b, const char *cp, size_t sz, int hexit)
{
-#if HAVE_GCRYPT_H
+#if HAVE_NETTLE
+ struct sha1_ctx ctx;
+ uint8_t digest[SHA1_DIGEST_SIZE];
+
+ sha1_init(&ctx);
+ sha1_update(&ctx, sz, (uint8_t *) cp);
+ sha1_digest(&ctx, SHA1_DIGEST_SIZE, digest);
+
+ if (hexit)
+ {
+ int i;
+ for (i = 0; i < SHA1_DIGEST_SIZE; i++)
+ wrbuf_printf(b, "%02x", digest[i]);
+ }
+ else
+ wrbuf_write(b, (const char *) digest, SHA1_DIGEST_SIZE);
+ return 0;
+#elif HAVE_GCRYPT_H
gcry_error_t e;
gcry_md_hd_t hd;
const unsigned char *digest_buf;
return 0;
}
-#if HAVE_GCRYPT_H
+#if HAVE_GCRYPT_H || HAVE_NETTLE
static void wrbuf_vary_puts(WRBUF w, const char *v)
{
if (v)
void ZOOM_memcached_resultset(ZOOM_resultset r, ZOOM_query q)
{
-#if HAVE_GCRYPT_H
+#if HAVE_GCRYPT_H || HAVE_NETTLE
ZOOM_connection c = r->connection;
r->mc_key = wrbuf_alloc();
test_odrcodec.c test_odrcodec.h: tstodr.asn $(YAZCOMP)
cd $(srcdir); $(YAZCOMP) tstodr.asn
-LDADD = ../src/libyaz.la
+LDADD = ../src/libyaz.la
test_icu_LDADD = ../src/libyaz_icu.la ../src/libyaz.la $(ICU_LIBS)
test_libstemmer_LDADD = ../src/libyaz_icu.la ../src/libyaz.la $(ICU_LIBS)
static int sha1_test(WRBUF wr, const char *msg, const char *expect)
{
wrbuf_rewind(wr);
-#if HAVE_GCRYPT_H
+#if HAVE_GCRYPT_H || HAVE_NETTLE
wrbuf_sha1_write(wr, msg, strlen(msg), 1);
if (!strcmp(wrbuf_cstr(wr), expect))
return 1;
{
char buf[100];
sprintf(buf, "Hello world %d", i);
-#if HAVE_GCRYPT_H
+#if HAVE_GCRYPT_H || HAVE_NETTLE
wrbuf_sha1_write(wr, buf, strlen(buf), 1);
#endif
wrbuf_rewind(wr);
wrbuf_insert(wr, 5, "abc", 3);
YAZ_CHECK(!strcmp(wrbuf_cstr(wr), "1234"));
- YAZ_CHECK(sha1_test(wr,
+ YAZ_CHECK(sha1_test(wr,
"Hello world\n",
"33ab5639bfd8e7b95eb1d8d0b87781d4ffea4d5d"));
ICU_CPPFLAGS="@ICU_CPPFLAGS@"
SSL_LIBS="@SSL_LIBS@"
GCRYPT_LIBS="@GCRYPT_LIBS@"
+NETTLE_LIBS="@NETTLE_LIBS@"
MEMCACHED_LIBS="@MEMCACHED_LIBS@"
HIREDIS_LIBS="@HIREDIS_LIBS@"
LIBS="@LIBS@"
else
YAZLIB="-L${build_root}/src/.libs $YAZLIB"
fi
- LIBS="${SSL_LIBS} ${GCRYPT_LIBS} ${MEMCACHED_LIBS} ${HIREDIS_LIBS} $LIBS"
+ LIBS="${SSL_LIBS} ${GCRYPT_LIBS} ${NETTLE_LIBS} ${MEMCACHED_LIBS} ${HIREDIS_LIBS} $LIBS"
YAZLIB="$YAZLIB $LIBS"
YAZLALIB="${build_root}/src/libyaz.la"