| 1 |
# af_alg.m4 |
| 2 |
# serial 6 |
| 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. |
| 7 |
dnl This file is offered as-is, without any warranty. |
| 8 |
|
| 9 |
dnl From Matteo Croce. |
| 10 |
|
| 11 |
AC_DEFUN_ONCE([gl_AF_ALG], |
| 12 |
[ |
| 13 |
AC_REQUIRE([gl_SYS_SOCKET_H]) |
| 14 |
AC_REQUIRE([AC_C_INLINE]) |
| 15 |
|
| 16 |
dnl Check whether linux/if_alg.h has needed features. |
| 17 |
AC_CACHE_CHECK([whether linux/if_alg.h has struct sockaddr_alg.], |
| 18 |
[gl_cv_header_linux_if_alg_salg], |
| 19 |
[AC_COMPILE_IFELSE( |
| 20 |
[AC_LANG_PROGRAM([[#include <sys/socket.h> |
| 21 |
#include <linux/if_alg.h> |
| 22 |
struct sockaddr_alg salg = { |
| 23 |
.salg_family = AF_ALG, |
| 24 |
.salg_type = "hash", |
| 25 |
.salg_name = "sha1", |
| 26 |
};]])], |
| 27 |
[gl_cv_header_linux_if_alg_salg=yes], |
| 28 |
[gl_cv_header_linux_if_alg_salg=no])]) |
| 29 |
if test "$gl_cv_header_linux_if_alg_salg" = yes; then |
| 30 |
AC_DEFINE([HAVE_LINUX_IF_ALG_H], [1], |
| 31 |
[Define to 1 if you have 'struct sockaddr_alg' defined.]) |
| 32 |
fi |
| 33 |
|
| 34 |
dnl The default is to not use AF_ALG if available, |
| 35 |
dnl as it's system dependent as to whether the kernel |
| 36 |
dnl routines are faster than libcrypto for example. |
| 37 |
use_af_alg=no |
| 38 |
AC_ARG_WITH([linux-crypto], |
| 39 |
[AS_HELP_STRING([[--with-linux-crypto]], |
| 40 |
[use Linux kernel cryptographic API (if available) for the hash functions |
| 41 |
MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512 on files])], |
| 42 |
[use_af_alg=$withval], |
| 43 |
[use_af_alg=no]) |
| 44 |
dnl We cannot use it if it is not available. |
| 45 |
if test "$gl_cv_header_linux_if_alg_salg" != yes; then |
| 46 |
if test "$use_af_alg" != no; then |
| 47 |
AC_MSG_WARN([Linux kernel cryptographic API not found]) |
| 48 |
fi |
| 49 |
use_af_alg=no |
| 50 |
fi |
| 51 |
|
| 52 |
if test "$use_af_alg" != no; then |
| 53 |
USE_AF_ALG=1 |
| 54 |
else |
| 55 |
USE_AF_ALG=0 |
| 56 |
fi |
| 57 |
AC_DEFINE_UNQUOTED([USE_LINUX_CRYPTO_API], [$USE_AF_ALG], |
| 58 |
[Define to 1 if you want to use the Linux kernel cryptographic API.]) |
| 59 |
]) |