+2018-05-06 Bruno Haible <bruno@clisp.org>
+
+ af_alg: Add configure option to enable/disable use of Linux crypto API.
+ Suggested by Assaf Gordon <assafgordon@gmail.com>.
+ * m4/af_alg.m4 (gl_AF_ALG): Add AC_ARG_WITH invocation. Define C macro
+ USE_LINUX_CRYPTO_API.
+ * lib/af_alg.h: Test USE_LINUX_CRYPTO_API, not HAVE_LINUX_IF_ALG_H.
+ * lib/af_alg.c: Likewise.
+
2018-05-06 Bruno Haible <bruno@clisp.org>
Followup to 'af_alg: New module.'.
extern "C" {
# endif
-# if HAVE_LINUX_IF_ALG_H
+# if USE_LINUX_CRYPTO_API
/* Compute a message digest of the contents of a file.
STREAM is an open file stream. Regular files are handled more efficiently.
-# af_alg.m4 serial 1
-dnl Check whether linux/if_alg.h has needed features.
-
+# af_alg.m4 serial 2
dnl Copyright 2018 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFUN_ONCE([gl_AF_ALG],
[
AC_REQUIRE([gl_HEADER_SYS_SOCKET])
+
+ dnl Check whether linux/if_alg.h has needed features.
AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
[gl_cv_header_linux_if_alg_salg],
[AC_COMPILE_IFELSE(
AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
[Define to 1 if you have 'struct sockaddr_alg' defined.])
fi
+
+ dnl The default is to use AF_ALG if available.
+ use_af_alg=yes
+ AC_ARG_WITH([linux-crypto],
+ [AS_HELP_STRING([[--without-linux-crypto]],
+ [Do not use Linux kernel cryptographic API (default is to use it if available)])
+ ],
+ [use_af_alg=$withval],
+ [use_af_alg=yes])
+ dnl We cannot use it if it is not available.
+ if test "$gl_cv_header_linux_if_alg_salg" != yes; then
+ use_af_alg=no
+ fi
+
+ if test "$use_af_alg" != no; then
+ USE_AF_ALG=1
+ else
+ USE_AF_ALG=0
+ fi
+ AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
+ [Define to 1 if you want to use the Linux kernel cryptographic API.])
])