3 dnl Copyright 2018-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
10 AC_DEFUN_ONCE([gl_AF_ALG],
12 AC_REQUIRE([gl_SYS_SOCKET_H])
13 AC_REQUIRE([AC_C_INLINE])
15 dnl Check whether linux/if_alg.h has needed features.
16 AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.],
17 [gl_cv_header_linux_if_alg_salg],
19 [AC_LANG_PROGRAM([[#include <sys/socket.h>
20 #include <linux/if_alg.h>
21 struct sockaddr_alg salg = {
22 .salg_family = AF_ALG,
26 [gl_cv_header_linux_if_alg_salg=yes],
27 [gl_cv_header_linux_if_alg_salg=no])])
28 if test "$gl_cv_header_linux_if_alg_salg" = yes; then
29 AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1],
30 [Define to 1 if you have 'struct sockaddr_alg' defined.])
33 dnl The default is to not use AF_ALG if available,
34 dnl as it's system dependent as to whether the kernel
35 dnl routines are faster than libcrypto for example.
37 AC_ARG_WITH([linux-crypto],
38 [AS_HELP_STRING([[--with-linux-crypto]],
39 [use Linux kernel cryptographic API (if available) for the hash functions
40 MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])],
41 [use_af_alg=$withval],
43 dnl We cannot use it if it is not available.
44 if test "$gl_cv_header_linux_if_alg_salg" != yes; then
45 if test "$use_af_alg" != no; then
46 AC_MSG_WARN([Linux kernel cryptographic API not found])
51 if test "$use_af_alg" != no; then
56 AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG],
57 [Define to 1 if you want to use the Linux kernel cryptographic API.])