From f9687b876e7faa65a1a897803ae5b07c94dd304e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?=
--enable-digests=LIST
Does nothing - only builtin content digests are available now: -MD5 and SHA1.
Select the list of content digests to be included if the are
+availble. The valid list of digests are: md5 sha1
+ripem160
(the default). The digest functions can be provided
+by external libraries such as the
+OpenSSL libcrypto library or by
+provided portable versions (only MD5 supported in this
+release).
--enable-parsers=LIST
Select the list of RDF parsers to be included if the are availble. The
diff --git a/configure.ac b/configure.ac
index ab4ffae8..c9986a5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -574,7 +574,56 @@ AC_MSG_RESULT($digest_modules)
DIGEST_OBJS=
DIGEST_SRCS=
+AC_ARG_WITH(openssl-digests, [ --with-openssl-digests Use openssl digests (default=yes)], enable_openssl_digests="$withval", enable_openssl_digests="yes")
+
+# This is needed because autoheader can't work out which computed
+# symbols must be pulled from acconfig.h into config.h.in
+if test "x" = "y"; then
+ AC_DEFINE(HAVE_OPENSSL_CRYPTO_MD5_DIGEST, 1, [Have openssl MD5 digest])
+ AC_DEFINE(HAVE_OPENSSL_CRYPTO_SHA1_DIGEST, 1, [Have openssl SHA1 digest])
+ AC_DEFINE(HAVE_OPENSSL_CRYPTO_RIPEMD160_DIGEST, 1, [Have openssl RIPEMD160 digest])
+fi
+
digest_modules_available=
+AC_MSG_CHECKING(whether to use openssl digests)
+if test "$enable_openssl_digests" = yes ; then
+ AC_MSG_RESULT(yes)
+ AC_CHECK_HEADERS(openssl/crypto.h)
+ if test "$ac_cv_header_openssl_crypto_h" = yes ; then
+ AC_DEFINE(HAVE_OPENSSL_DIGESTS, 1, [Have openssl digests])
+ new_digest_modules=
+ LIBS="$LIBRDF_LIBS -lcrypto"
+ have_libcrypto=no
+
+ for module in $digest_modules; do
+ func=`echo $module | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ found=
+ AC_MSG_CHECKING(for openssl $func digest module)
+ AC_CACHE_VAL(ac_cv_lib_crypto_$func,
+ [AC_TRY_LINK(, $func(),
+ [eval "ac_cv_lib_crypto_$func=yes"],
+ [eval "ac_cv_lib_crypto_$func=no"])])
+ if eval "test \"`echo '$ac_cv_lib_crypto_'$func`\" = yes"; then
+ AC_MSG_RESULT(yes)
+ n=HAVE_OPENSSL_CRYPTO_${func}_DIGEST
+ AC_DEFINE_UNQUOTED($n)
+ have_libcrypto=yes
+ digest_modules_available="$digest_modules_available $module(openssl)"
+ else
+ AC_MSG_RESULT(no)
+ new_digest_modules="${new_digest_modules} $module"
+ fi
+ done
+ if test "$have_libcrypto" = yes; then
+ LIBRDF_LIBS="$LIBRDF_LIBS -lcrypto"
+ fi
+ DIGEST_OBJS="$DIGEST_OBJS rdf_digest_openssl.lo"
+ DIGEST_SRCS="$DIGEST_SRCS rdf_digest_openssl.c"
+ digest_modules=$new_digest_modules
+ fi
+else
+ AC_MSG_RESULT(no)
+fi
dnl hashes
diff --git a/src/Makefile.am b/src/Makefile.am
index b0b708b8..cb32d058 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -189,7 +189,7 @@ librdf_la_DEPENDENCIES = \
@LIBRDF_INTERNAL_DEPS@
EXTRA_librdf_la_SOURCES = rdf_hash_bdb.c \
-rdf_digest_md5.c rdf_digest_sha1.c \
+rdf_digest_md5.c rdf_digest_sha1.c rdf_digest_openssl.c \
rdf_parser_raptor.c
EXTRA_DIST=\
diff --git a/src/rdf_digest_openssl.c b/src/rdf_digest_openssl.c
new file mode 100644
index 00000000..be04cb4f
--- /dev/null
+++ b/src/rdf_digest_openssl.c
@@ -0,0 +1,188 @@
+/* -*- Mode: c; c-basic-offset: 2 -*-
+ *
+ * rdf_digest_openssl.c - RDF Digest OpenSSL Digest interface
+ *
+ * Copyright (C) 2000-2008, David Beckett http://www.dajobe.org/
+ * Copyright (C) 2000-2004, University of Bristol, UK http://www.bristol.ac.uk/
+ *
+ * This package is Free Software and part of Redland http://librdf.org/
+ *
+ * It is licensed under the following three licenses as alternatives:
+ * 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
+ * 2. GNU General Public License (GPL) V2 or any newer version
+ * 3. Apache License, V2.0 or any newer version
+ *
+ * You may not use this file except in compliance with at least one of
+ * the above three licenses.
+ *
+ * See LICENSE.html or LICENSE.txt at the top of this package for the
+ * complete terms and further detail along with the license texts for
+ * the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
+ *
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include