]> Savannah Git Hosting - gnulib.git/commitdiff
af_alg: Add configure option to enable/disable use of Linux crypto API.
authorBruno Haible <bruno@clisp.org>
Sun, 6 May 2018 10:23:55 +0000 (12:23 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 6 May 2018 10:23:55 +0000 (12:23 +0200)
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.

ChangeLog
lib/af_alg.c
lib/af_alg.h
m4/af_alg.m4

index 572035542ba0f8d7640393e573186259a0cf4018..dd55a444b79cd34bd341be1e32e744b92290f227 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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.'.
index 3b35e019b4ab4ad5edef83f0c0dd6563bfc81e71..97bdff516bd5c83c3bc7a59f164d8817552be427 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <config.h>
 
-#if HAVE_LINUX_IF_ALG_H
+#if USE_LINUX_CRYPTO_API
 
 #include "af_alg.h"
 
index 2545ec6ec213fd794dbb51c3650d0d8f7796de7e..a15a9565132de4dfd436ce2e28b7c99fbc11d02d 100644 (file)
@@ -35,7 +35,7 @@
 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.
index 1c57e2ca227bda622f1d77098e3815d2c35370f6..f7176f37e56172d12945f024b405181bbde40b3f 100644 (file)
@@ -1,6 +1,4 @@
-# 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,
@@ -11,6 +9,8 @@ dnl From Matteo Croce.
 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(
@@ -27,4 +27,25 @@ AC_DEFUN_ONCE([gl_AF_ALG],
     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.])
 ])