2 AC_INIT([cryptsetup],[2.6.1])
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=21:0:9
9 AC_CONFIG_SRCDIR(src/cryptsetup.c)
10 AC_CONFIG_MACRO_DIR([m4])
12 AC_CONFIG_HEADERS([config.h:config.h.in])
14 # We do not want to run test in parallel. Really.
15 # http://lists.gnu.org/archive/html/automake/2013-01/msg00060.html
17 # For old automake use this
18 #AM_INIT_AUTOMAKE(dist-xz subdir-objects)
19 AM_INIT_AUTOMAKE([dist-xz 1.12 serial-tests subdir-objects foreign])
21 if test "x$prefix" = "xNONE"; then
24 AC_PREFIX_DEFAULT(/usr)
27 AC_USE_SYSTEM_EXTENSIONS
39 dnl ==========================================================================
40 dnl define PKG_CHECK_VAR for old pkg-config <= 0.28
41 m4_ifndef([AS_VAR_COPY],
42 [m4_define([AS_VAR_COPY],
43 [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])
45 m4_ifndef([PKG_CHECK_VAR], [
46 AC_DEFUN([PKG_CHECK_VAR],
47 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
48 AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])
50 _PKG_CONFIG([$1], [variable="][$3]["], [$2])
51 AS_VAR_COPY([$1], [pkg_cv_][$1])
53 AS_VAR_IF([$1], [""], [$5], [$4])
56 dnl ==========================================================================
57 dnl AsciiDoc manual pages
59 AC_ARG_ENABLE([asciidoc],
60 AS_HELP_STRING([--disable-asciidoc], [do not generate man pages from asciidoc]),
61 [], [enable_asciidoc=yes]
64 AC_PATH_PROG([ASCIIDOCTOR], [asciidoctor])
65 if test "x$enable_asciidoc" = xyes -a "x$ASCIIDOCTOR" = x; then
66 AC_MSG_ERROR([Building man pages requires asciidoctor installed.])
68 AM_CONDITIONAL([ENABLE_ASCIIDOC], [test "x$enable_asciidoc" = xyes])
71 AS_IF([test -f "$srcdir/man/cryptsetup-open.8"], [
72 AC_MSG_NOTICE([re-use already generated man-pages.])
75 AM_CONDITIONAL([HAVE_MANPAGES], [test "x$have_manpages" = xyes])
77 dnl ==========================================================================
82 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h uchar.h sys/ioctl.h sys/mman.h \
83 sys/sysmacros.h sys/statvfs.h ctype.h unistd.h locale.h byteswap.h endian.h stdint.h)
84 AC_CHECK_DECLS([O_CLOEXEC],,[AC_DEFINE([O_CLOEXEC],[0], [Defined to 0 if not provided])],
91 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
92 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
94 AC_ARG_ENABLE([keyring],
95 AS_HELP_STRING([--disable-keyring], [disable kernel keyring support and builtin kernel keyring token]),
96 [], [enable_keyring=yes])
97 if test "x$enable_keyring" = "xyes"; then
98 AC_CHECK_HEADERS(linux/keyctl.h,,[AC_MSG_ERROR([You need Linux kernel headers with kernel keyring service compiled.])])
100 dnl ==========================================================================
101 dnl check whether kernel is compiled with kernel keyring service syscalls
102 AC_CHECK_DECL(__NR_add_key,,[AC_MSG_ERROR([The kernel is missing add_key syscall.])], [#include <syscall.h>])
103 AC_CHECK_DECL(__NR_keyctl,,[AC_MSG_ERROR([The kernel is missing keyctl syscall.])], [#include <syscall.h>])
104 AC_CHECK_DECL(__NR_request_key,,[AC_MSG_ERROR([The kernel is missing request_key syscall.])], [#include <syscall.h>])
106 dnl ==========================================================================
107 dnl check that key_serial_t hasn't been adopted yet in stdlib
108 AC_CHECK_TYPES([key_serial_t], [], [], [
110 #ifdef HAVE_LINUX_KEYCTL_H
111 # include <linux/keyctl.h>
115 AC_DEFINE(KERNEL_KEYRING, 1, [Enable kernel keyring service support])
117 AM_CONDITIONAL(KERNEL_KEYRING, test "x$enable_keyring" = "xyes")
120 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
121 AC_SUBST(UUID_LIBS, $LIBS)
124 AC_SEARCH_LIBS([clock_gettime],[rt posix4])
125 AC_CHECK_FUNCS([posix_memalign clock_gettime posix_fallocate explicit_bzero])
127 if test "x$enable_largefile" = "xno"; then
128 AC_MSG_ERROR([Building with --disable-largefile is not supported, it can cause data corruption.])
136 AC_PROG_GCC_TRADITIONAL
139 dnl ==========================================================================
140 dnl LUKS2 external tokens
142 AC_ARG_ENABLE([external-tokens],
143 AS_HELP_STRING([--disable-external-tokens], [disable external LUKS2 tokens]),
144 [], [enable_external_tokens=yes])
145 if test "x$enable_external_tokens" = "xyes"; then
146 AC_DEFINE(USE_EXTERNAL_TOKENS, 1, [Use external tokens])
147 dnl we need dynamic library loading here
149 AC_SEARCH_LIBS([dlsym],[dl])
150 AC_CHECK_FUNCS([dlvsym])
151 AC_SUBST(DL_LIBS, $LIBS)
154 AM_CONDITIONAL(EXTERNAL_TOKENS, test "x$enable_external_tokens" = "xyes")
156 AC_ARG_ENABLE([ssh-token],
157 AS_HELP_STRING([--disable-ssh-token], [disable LUKS2 ssh-token]),
158 [], [enable_ssh_token=yes])
159 AM_CONDITIONAL(SSHPLUGIN_TOKEN, test "x$enable_ssh_token" = "xyes")
161 if test "x$enable_ssh_token" = "xyes" -a "x$enable_external_tokens" = "xno"; then
162 AC_MSG_ERROR([Requested LUKS2 ssh-token build, but external tokens are disabled.])
165 dnl LUKS2 online reencryption
166 AC_ARG_ENABLE([luks2-reencryption],
167 AS_HELP_STRING([--disable-luks2-reencryption], [disable LUKS2 online reencryption extension]),
168 [], [enable_luks2_reencryption=yes])
169 if test "x$enable_luks2_reencryption" = "xyes"; then
170 AC_DEFINE(USE_LUKS2_REENCRYPTION, 1, [Use LUKS2 online reencryption extension])
173 dnl ==========================================================================
175 AM_GNU_GETTEXT([external],[need-ngettext])
176 AM_GNU_GETTEXT_VERSION([0.18.3])
178 dnl ==========================================================================
181 AC_CHECK_LIB(popt, poptConfigFileToString,,
182 [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
183 AC_SUBST(POPT_LIBS, $LIBS)
186 dnl ==========================================================================
188 AC_ARG_ENABLE([fips],
189 AS_HELP_STRING([--enable-fips], [enable FIPS mode restrictions]))
190 if test "x$enable_fips" = "xyes"; then
191 AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
193 if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
194 AC_MSG_ERROR([Static build is not compatible with FIPS.])
198 AC_DEFUN([NO_FIPS], [
199 if test "x$enable_fips" = "xyes"; then
200 AC_MSG_ERROR([This option is not compatible with FIPS.])
204 dnl ==========================================================================
205 dnl pwquality library (cryptsetup CLI only)
206 AC_ARG_ENABLE([pwquality],
207 AS_HELP_STRING([--enable-pwquality], [enable password quality checking using pwquality library]))
209 if test "x$enable_pwquality" = "xyes"; then
210 AC_DEFINE(ENABLE_PWQUALITY, 1, [Enable password quality checking using pwquality library])
211 PKG_CHECK_MODULES([PWQUALITY], [pwquality >= 1.0.0],,
212 AC_MSG_ERROR([You need pwquality library.]))
214 dnl FIXME: this is really hack for now
215 PWQUALITY_STATIC_LIBS="$PWQUALITY_LIBS -lcrack -lz"
218 dnl ==========================================================================
219 dnl fuzzers, it requires own static library compilation later
220 AC_ARG_ENABLE([fuzz-targets],
221 AS_HELP_STRING([--enable-fuzz-targets], [enable building fuzz targets]))
222 AM_CONDITIONAL(ENABLE_FUZZ_TARGETS, test "x$enable_fuzz_targets" = "xyes")
224 if test "x$enable_fuzz_targets" = "xyes"; then
225 AX_CHECK_COMPILE_FLAG([-fsanitize=fuzzer-no-link],,
226 AC_MSG_ERROR([Required compiler options not supported; use clang.]), [-Werror])
229 dnl ==========================================================================
230 dnl passwdqc library (cryptsetup CLI only)
231 AC_ARG_ENABLE([passwdqc],
232 AS_HELP_STRING([--enable-passwdqc@<:@=CONFIG_PATH@:>@],
233 [enable password quality checking using passwdqc library (optionally with CONFIG_PATH)]))
235 case "$enable_passwdqc" in
236 ""|yes|no) use_passwdqc_config="" ;;
237 /*) use_passwdqc_config="$enable_passwdqc"; enable_passwdqc=yes ;;
238 *) AC_MSG_ERROR([Unrecognized --enable-passwdqc parameter.]) ;;
240 AC_DEFINE_UNQUOTED([PASSWDQC_CONFIG_FILE], ["$use_passwdqc_config"], [passwdqc library config file])
242 if test "x$enable_passwdqc" = "xyes"; then
243 AC_DEFINE(ENABLE_PASSWDQC, 1, [Enable password quality checking using passwdqc library])
246 AC_SEARCH_LIBS([passwdqc_check], [passwdqc])
247 case "$ac_cv_search_passwdqc_check" in
248 no) AC_MSG_ERROR([failed to find passwdqc_check]) ;;
249 -l*) PASSWDQC_LIBS="$ac_cv_search_passwdqc_check" ;;
252 AC_CHECK_FUNCS([passwdqc_params_free])
256 if test "x$enable_pwquality$enable_passwdqc" = "xyesyes"; then
257 AC_MSG_ERROR([--enable-pwquality and --enable-passwdqc are mutually incompatible.])
260 dnl ==========================================================================
261 dnl Crypto backend functions
263 AC_DEFUN([CONFIGURE_GCRYPT], [
264 if test "x$enable_fips" = "xyes"; then
265 GCRYPT_REQ_VERSION=1.4.5
267 GCRYPT_REQ_VERSION=1.1.42
270 dnl libgcrypt rejects to use pkgconfig, use AM_PATH_LIBGCRYPT from gcrypt-devel here.
271 dnl Do not require gcrypt-devel if other crypto backend is used.
272 m4_ifdef([AM_PATH_LIBGCRYPT],[
273 AC_ARG_ENABLE([gcrypt-pbkdf2],
274 dnl Check if we can use gcrypt PBKDF2 (1.6.0 supports empty password)
275 AS_HELP_STRING([--enable-gcrypt-pbkdf2], [force enable internal gcrypt PBKDF2]),
276 if test "x$enableval" = "xyes"; then
277 [use_internal_pbkdf2=0]
279 [use_internal_pbkdf2=1]
281 [AM_PATH_LIBGCRYPT([1.6.1], [use_internal_pbkdf2=0], [use_internal_pbkdf2=1])])
282 AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])],
283 AC_MSG_ERROR([Missing support for gcrypt: install gcrypt and regenerate configure.]))
285 AC_MSG_CHECKING([if internal cryptsetup PBKDF2 is compiled-in])
286 if test $use_internal_pbkdf2 = 0; then
293 AC_CHECK_DECLS([GCRY_CIPHER_MODE_XTS], [], [], [#include <gcrypt.h>])
295 if test "x$enable_static_cryptsetup" = "xyes"; then
297 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
298 AC_CHECK_LIB(gcrypt, gcry_check_version,,
299 AC_MSG_ERROR([Cannot find static gcrypt library.]),
301 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
305 CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
306 CRYPTO_LIBS=$LIBGCRYPT_LIBS
307 CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
309 AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
312 AC_DEFUN([CONFIGURE_OPENSSL], [
313 PKG_CHECK_MODULES([OPENSSL], [openssl3 >= 3.0.9],,
314 AC_MSG_ERROR([You need openssl library.]))
315 CRYPTO_CFLAGS=$OPENSSL_CFLAGS
316 CRYPTO_LIBS=$OPENSSL_LIBS
317 use_internal_pbkdf2=0
319 if test "x$enable_static_cryptsetup" = "xyes"; then
320 saved_PKG_CONFIG=$PKG_CONFIG
321 PKG_CONFIG="$PKG_CONFIG --static"
322 PKG_CHECK_MODULES([OPENSSL_STATIC], [openssl])
323 CRYPTO_STATIC_LIBS=$OPENSSL_STATIC_LIBS
324 PKG_CONFIG=$saved_PKG_CONFIG
328 AC_DEFUN([CONFIGURE_NSS], [
329 if test "x$enable_static_cryptsetup" = "xyes"; then
330 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
333 AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
335 PKG_CHECK_MODULES([NSS], [nss],,
336 AC_MSG_ERROR([You need nss library.]))
339 CFLAGS="$CFLAGS $NSS_CFLAGS"
340 AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
343 CRYPTO_CFLAGS=$NSS_CFLAGS
344 CRYPTO_LIBS=$NSS_LIBS
345 use_internal_pbkdf2=1
349 AC_DEFUN([CONFIGURE_KERNEL], [
350 AC_CHECK_HEADERS(linux/if_alg.h,,
351 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface.])])
352 # AC_CHECK_DECLS([AF_ALG],,
353 # [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
354 # [#include <sys/socket.h>])
355 use_internal_pbkdf2=1
359 AC_DEFUN([CONFIGURE_NETTLE], [
360 AC_CHECK_HEADERS(nettle/sha.h,,
361 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
362 AC_CHECK_HEADERS(nettle/version.h)
365 AC_CHECK_LIB(nettle, nettle_pbkdf2_hmac_sha256,,
366 [AC_MSG_ERROR([You need Nettle library version 2.6 or more recent.])])
370 CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
371 use_internal_pbkdf2=0
375 dnl ==========================================================================
378 AC_ARG_ENABLE([static-cryptsetup],
379 AS_HELP_STRING([--enable-static-cryptsetup], [enable build of static version of tools]))
380 if test "x$enable_static_cryptsetup" = "xyes"; then
381 if test "x$enable_static" = "xno"; then
382 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
386 AM_CONDITIONAL(STATIC_TOOLS, test "x$enable_static_cryptsetup" = "xyes")
388 AC_ARG_ENABLE([cryptsetup],
389 AS_HELP_STRING([--disable-cryptsetup], [disable cryptsetup support]),
390 [], [enable_cryptsetup=yes])
391 AM_CONDITIONAL(CRYPTSETUP, test "x$enable_cryptsetup" = "xyes")
393 AC_ARG_ENABLE([veritysetup],
394 AS_HELP_STRING([--disable-veritysetup], [disable veritysetup support]),
395 [], [enable_veritysetup=yes])
396 AM_CONDITIONAL(VERITYSETUP, test "x$enable_veritysetup" = "xyes")
398 AC_ARG_ENABLE([integritysetup],
399 AS_HELP_STRING([--disable-integritysetup], [disable integritysetup support]),
400 [], [enable_integritysetup=yes])
401 AM_CONDITIONAL(INTEGRITYSETUP, test "x$enable_integritysetup" = "xyes")
403 AC_ARG_ENABLE([selinux],
404 AS_HELP_STRING([--disable-selinux], [disable selinux support [default=auto]]),
405 [], [enable_selinux=yes])
407 AC_ARG_ENABLE([udev],
408 AS_HELP_STRING([--disable-udev], [disable udev support]),
409 [], [enable_udev=yes])
411 dnl Try to use pkg-config for devmapper, but fallback to old detection
412 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
413 AC_CHECK_LIB(devmapper, dm_task_set_name,,
414 [AC_MSG_ERROR([You need the device-mapper library.])])
415 AC_CHECK_LIB(devmapper, dm_task_set_message,,
416 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
421 LIBS="$LIBS $DEVMAPPER_LIBS"
422 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
423 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
424 AC_CHECK_DECLS([dm_task_deferred_remove], [], [], [#include <libdevmapper.h>])
425 AC_CHECK_DECLS([dm_device_has_mounted_fs], [], [], [#include <libdevmapper.h>])
426 AC_CHECK_DECLS([dm_device_has_holders], [], [], [#include <libdevmapper.h>])
427 AC_CHECK_DECLS([dm_device_get_name], [], [], [#include <libdevmapper.h>])
428 AC_CHECK_DECLS([DM_DEVICE_GET_TARGET_VERSION], [], [], [#include <libdevmapper.h>])
429 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
430 if test "x$enable_udev" = xyes; then
431 if test "x$have_cookie" = xno; then
432 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
434 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
439 dnl Check for JSON-C used in LUKS2
440 PKG_CHECK_MODULES([JSON_C], [json-c])
441 AC_CHECK_DECLS([json_object_object_add_ex], [], [], [#include <json-c/json.h>])
442 AC_CHECK_DECLS([json_object_deep_copy], [], [], [#include <json-c/json.h>])
444 dnl Check for libssh and argp for SSH plugin
445 if test "x$enable_ssh_token" = "xyes"; then
446 PKG_CHECK_MODULES([LIBSSH], [libssh])
447 AC_CHECK_DECLS([ssh_session_is_known_server], [], [], [#include <libssh/libssh.h>])
448 AC_CHECK_HEADER([argp.h], [], AC_MSG_ERROR([You need argp library.]))
450 AC_SEARCH_LIBS([argp_parse],[argp])
451 AC_SUBST(ARGP_LIBS, $LIBS)
455 dnl Crypto backend configuration.
456 AC_ARG_WITH([crypto_backend],
457 AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [openssl]]),
458 [], [with_crypto_backend=openssl])
460 dnl Kernel crypto API backend needed for benchmark and tcrypt
461 AC_ARG_ENABLE([kernel_crypto],
462 AS_HELP_STRING([--disable-kernel_crypto], [disable kernel userspace crypto (no benchmark and tcrypt)]),
463 [], [enable_kernel_crypto=yes])
465 if test "x$enable_kernel_crypto" = "xyes"; then
466 AC_CHECK_HEADERS(linux/if_alg.h,,
467 [AC_MSG_ERROR([You need Linux kernel headers with userspace crypto interface. (Or use --disable-kernel_crypto.)])])
468 AC_DEFINE(ENABLE_AF_ALG, 1, [Enable using of kernel userspace crypto])
471 case $with_crypto_backend in
472 gcrypt) CONFIGURE_GCRYPT([]) ;;
473 openssl) CONFIGURE_OPENSSL([]) ;;
474 nss) CONFIGURE_NSS([]) ;;
475 kernel) CONFIGURE_KERNEL([]) ;;
476 nettle) CONFIGURE_NETTLE([]) ;;
477 *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
479 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT, test "$with_crypto_backend" = "gcrypt")
480 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test "$with_crypto_backend" = "openssl")
481 AM_CONDITIONAL(CRYPTO_BACKEND_NSS, test "$with_crypto_backend" = "nss")
482 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL, test "$with_crypto_backend" = "kernel")
483 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE, test "$with_crypto_backend" = "nettle")
485 AM_CONDITIONAL(CRYPTO_INTERNAL_PBKDF2, test $use_internal_pbkdf2 = 1)
486 AC_DEFINE_UNQUOTED(USE_INTERNAL_PBKDF2, [$use_internal_pbkdf2], [Use internal PBKDF2])
488 dnl Argon2 implementation
489 AC_ARG_ENABLE([internal-argon2],
490 AS_HELP_STRING([--disable-internal-argon2], [disable internal implementation of Argon2 PBKDF]),
491 [], [enable_internal_argon2=yes])
493 AC_ARG_ENABLE([libargon2],
494 AS_HELP_STRING([--enable-libargon2], [enable external libargon2 (PHC) library (disables internal bundled version)]))
496 if test "x$enable_libargon2" = "xyes" ; then
497 AC_CHECK_HEADERS(argon2.h,,
498 [AC_MSG_ERROR([You need libargon2 development library installed.])])
499 AC_CHECK_DECL(Argon2_id,,[AC_MSG_ERROR([You need more recent Argon2 library with support for Argon2id.])], [#include <argon2.h>])
500 PKG_CHECK_MODULES([LIBARGON2], [libargon2],,[LIBARGON2_LIBS="-largon2"])
501 enable_internal_argon2=no
503 AC_MSG_WARN([Argon2 bundled (slow) reference implementation will be used, please consider to use system library with --enable-libargon2.])
505 AC_ARG_ENABLE([internal-sse-argon2],
506 AS_HELP_STRING([--enable-internal-sse-argon2], [enable internal SSE implementation of Argon2 PBKDF]))
508 if test "x$enable_internal_sse_argon2" = "xyes"; then
509 AC_MSG_CHECKING(if Argon2 SSE optimization can be used)
510 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
511 #include <emmintrin.h>
512 __m128i testfunc(__m128i *a, __m128i *b) {
513 return _mm_xor_si128(_mm_loadu_si128(a), _mm_loadu_si128(b));
515 ]])],,[enable_internal_sse_argon2=no])
516 AC_MSG_RESULT($enable_internal_sse_argon2)
520 if test "x$enable_internal_argon2" = "xyes"; then
521 AC_DEFINE(USE_INTERNAL_ARGON2, 1, [Use internal Argon2])
523 AM_CONDITIONAL(CRYPTO_INTERNAL_ARGON2, test "x$enable_internal_argon2" = "xyes")
524 AM_CONDITIONAL(CRYPTO_INTERNAL_SSE_ARGON2, test "x$enable_internal_sse_argon2" = "xyes")
526 dnl Link with blkid to check for other device types
527 AC_ARG_ENABLE([blkid],
528 AS_HELP_STRING([--disable-blkid], [disable use of blkid for device signature detection and wiping]),
529 [], [enable_blkid=yes])
531 if test "x$enable_blkid" = "xyes"; then
532 PKG_CHECK_MODULES([BLKID], [blkid],[AC_DEFINE([HAVE_BLKID], 1, [Define to 1 to use blkid for detection of disk signatures.])],[LIBBLKID_LIBS="-lblkid"])
534 AC_CHECK_HEADERS(blkid/blkid.h,,[AC_MSG_ERROR([You need blkid development library installed.])])
535 AC_CHECK_DECL([blkid_do_wipe],
536 [ AC_DEFINE([HAVE_BLKID_WIPE], 1, [Define to 1 to use blkid_do_wipe.])
537 enable_blkid_wipe=yes
539 [#include <blkid/blkid.h>])
540 AC_CHECK_DECL([blkid_probe_step_back],
541 [ AC_DEFINE([HAVE_BLKID_STEP_BACK], 1, [Define to 1 to use blkid_probe_step_back.])
542 enable_blkid_step_back=yes
544 [#include <blkid/blkid.h>])
545 AC_CHECK_DECLS([ blkid_reset_probe,
546 blkid_probe_set_device,
547 blkid_probe_filter_superblocks_type,
550 blkid_probe_lookup_value
552 [AC_MSG_ERROR([Can not compile with blkid support, disable it by --disable-blkid.])],
553 [#include <blkid/blkid.h>])
555 AM_CONDITIONAL(HAVE_BLKID, test "x$enable_blkid" = "xyes")
556 AM_CONDITIONAL(HAVE_BLKID_WIPE, test "x$enable_blkid_wipe" = "xyes")
557 AM_CONDITIONAL(HAVE_BLKID_STEP_BACK, test "x$enable_blkid_step_back" = "xyes")
559 dnl Magic for cryptsetup.static build.
560 if test "x$enable_static_cryptsetup" = "xyes"; then
561 saved_PKG_CONFIG=$PKG_CONFIG
562 PKG_CONFIG="$PKG_CONFIG --static"
564 LIBS="$saved_LIBS -static"
565 AC_CHECK_LIB(popt, poptGetContext,,
566 AC_MSG_ERROR([Cannot find static popt library.]))
568 dnl Try to detect needed device-mapper static libraries, try pkg-config first.
569 LIBS="$saved_LIBS -static"
570 PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
571 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
572 if test "x$enable_selinux" = "xyes"; then
573 AC_CHECK_LIB(sepol, sepol_bool_set)
574 AC_CHECK_LIB(selinux, is_selinux_enabled)
575 DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
578 LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
579 AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
580 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
582 dnl Try to detect uuid static library.
583 LIBS="$saved_LIBS -static"
584 AC_CHECK_LIB(uuid, uuid_generate,,
585 AC_MSG_ERROR([Cannot find static uuid library.]))
588 PKG_CONFIG=$saved_PKG_CONFIG
591 dnl Check compiler support for symver function attribute
592 AC_MSG_CHECKING([for symver attribute support])
595 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
596 void _test_sym(void);
597 __attribute__((__symver__("sym@VERSION_4.2"))) void _test_sym(void) {}
601 AC_DEFINE([HAVE_ATTRIBUTE_SYMVER], 1, [Define to 1 to use __attribute__((symver))])
608 AC_MSG_CHECKING([for systemd tmpfiles config directory])
609 PKG_CHECK_VAR([systemd_tmpfilesdir], [systemd], [tmpfilesdir], [], [systemd_tmpfilesdir=no])
610 AC_MSG_RESULT([$systemd_tmpfilesdir])
612 AC_SUBST([DEVMAPPER_LIBS])
613 AC_SUBST([DEVMAPPER_STATIC_LIBS])
615 AC_SUBST([PWQUALITY_LIBS])
616 AC_SUBST([PWQUALITY_STATIC_LIBS])
618 AC_SUBST([PASSWDQC_LIBS])
620 AC_SUBST([CRYPTO_CFLAGS])
621 AC_SUBST([CRYPTO_LIBS])
622 AC_SUBST([CRYPTO_STATIC_LIBS])
624 AC_SUBST([JSON_C_LIBS])
625 AC_SUBST([LIBARGON2_LIBS])
626 AC_SUBST([BLKID_LIBS])
628 AC_SUBST([LIBSSH_LIBS])
630 AC_SUBST([LIBCRYPTSETUP_VERSION])
631 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
633 dnl Set Requires.private for libcryptsetup.pc
634 dnl pwquality is used only by tools
635 PKGMODULES="uuid devmapper json-c"
636 case $with_crypto_backend in
637 gcrypt) PKGMODULES+=" libgcrypt" ;;
638 openssl) PKGMODULES+=" openssl" ;;
639 nss) PKGMODULES+=" nss" ;;
640 nettle) PKGMODULES+=" nettle" ;;
642 if test "x$enable_libargon2" = "xyes"; then
643 PKGMODULES+=" libargon2"
645 if test "x$enable_blkid" = "xyes"; then
648 AC_SUBST([PKGMODULES])
649 dnl ==========================================================================
650 AC_ARG_ENABLE([dev-random],
651 AS_HELP_STRING([--enable-dev-random], [use /dev/random by default for key generation (otherwise use /dev/urandom)]))
652 if test "x$enable_dev_random" = "xyes"; then
653 default_rng=/dev/random
655 default_rng=/dev/urandom
657 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
659 dnl ==========================================================================
660 AC_DEFUN([CS_DEFINE],
661 [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
664 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
665 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
666 [CS_DEFINE([$1], ["$withval"], [$2])],
667 [CS_DEFINE([$1], ["$3"], [$2])]
670 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
671 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
672 [CS_DEFINE([$1], [$withval], [$2])],
673 [CS_DEFINE([$1], [$3], [$2])]
676 AC_DEFUN([CS_ABSPATH], [
679 *) AC_MSG_ERROR([$2 argument must be an absolute path.]);;
683 dnl ==========================================================================
684 CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
685 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
686 CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
687 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
689 CS_STR_WITH([luks1-hash], [hash function for LUKS1 header], [sha256])
690 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
691 CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [xts-plain64])
692 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
694 AC_ARG_ENABLE([luks_adjust_xts_keysize], AS_HELP_STRING([--disable-luks-adjust-xts-keysize],
695 [XTS mode requires two keys, double default LUKS keysize if needed]),
696 [], [enable_luks_adjust_xts_keysize=yes])
697 if test "x$enable_luks_adjust_xts_keysize" = "xyes"; then
698 AC_DEFINE(ENABLE_LUKS_ADJUST_XTS_KEYSIZE, 1, [XTS mode - double default LUKS keysize if needed])
701 CS_STR_WITH([luks2-pbkdf], [Default PBKDF algorithm (pbkdf2 or argon2i/argon2id) for LUKS2], [argon2id])
702 CS_NUM_WITH([luks1-iter-time], [PBKDF2 iteration time for LUKS1 (in ms)], [2000])
703 CS_NUM_WITH([luks2-iter-time], [Argon2 PBKDF iteration time for LUKS2 (in ms)], [2000])
704 CS_NUM_WITH([luks2-memory-kb], [Argon2 PBKDF memory cost for LUKS2 (in kB)], [1048576])
705 CS_NUM_WITH([luks2-parallel-threads],[Argon2 PBKDF max parallel cost for LUKS2 (if CPUs available)], [4])
707 CS_STR_WITH([luks2-keyslot-cipher], [fallback cipher for LUKS2 keyslot (if data encryption is incompatible)], [aes-xts-plain64])
708 CS_NUM_WITH([luks2-keyslot-keybits],[fallback key size for LUKS2 keyslot (if data encryption is incompatible)], [512])
710 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
711 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
713 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
714 CS_NUM_WITH([integrity-keyfile-size-maxkb],[maximum integritysetup keyfile size (in KiB)], [4])
715 CS_NUM_WITH([passphrase-size-max],[maximum passphrase size (in characters)], [512])
717 CS_STR_WITH([verity-hash], [hash function for verity mode], [sha256])
718 CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
719 CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
720 CS_NUM_WITH([verity-salt-size], [salt size for verity mode], [32])
721 CS_NUM_WITH([verity-fec-roots], [parity bytes for verity FEC], [2])
723 CS_STR_WITH([tmpfilesdir], [override default path to directory with systemd temporary files], [])
724 test -z "$with_tmpfilesdir" && with_tmpfilesdir=$systemd_tmpfilesdir
725 test "x$with_tmpfilesdir" = "xno" || {
726 CS_ABSPATH([${with_tmpfilesdir}],[with-tmpfilesdir])
727 DEFAULT_TMPFILESDIR=$with_tmpfilesdir
728 AC_SUBST(DEFAULT_TMPFILESDIR)
730 AM_CONDITIONAL(CRYPTSETUP_TMPFILE, test -n "$DEFAULT_TMPFILESDIR")
732 CS_STR_WITH([luks2-lock-path], [path to directory for LUKSv2 locks], [/run/cryptsetup])
733 test -z "$with_luks2_lock_path" && with_luks2_lock_path=/run/cryptsetup
734 CS_ABSPATH([${with_luks2_lock_path}],[with-luks2-lock-path])
735 DEFAULT_LUKS2_LOCK_PATH=$with_luks2_lock_path
736 AC_SUBST(DEFAULT_LUKS2_LOCK_PATH)
738 CS_NUM_WITH([luks2-lock-dir-perms], [default luks2 locking directory permissions], [0700])
739 test -z "$with_luks2_lock_dir_perms" && with_luks2_lock_dir_perms=0700
740 DEFAULT_LUKS2_LOCK_DIR_PERMS=$with_luks2_lock_dir_perms
741 AC_SUBST(DEFAULT_LUKS2_LOCK_DIR_PERMS)
743 CS_STR_WITH([luks2-external-tokens-path], [path to directory with LUKSv2 external token handlers (plugins)], [LIBDIR/cryptsetup])
744 if test -n "$with_luks2_external_tokens_path"; then
745 CS_ABSPATH([${with_luks2_external_tokens_path}],[with-luks2-external-tokens-path])
746 EXTERNAL_LUKS2_TOKENS_PATH=$with_luks2_external_tokens_path
748 EXTERNAL_LUKS2_TOKENS_PATH="\${libdir}/cryptsetup"
750 AC_SUBST(EXTERNAL_LUKS2_TOKENS_PATH)
752 dnl Override default LUKS format version (for cryptsetup or cryptsetup-reencrypt format actions only).
753 AC_ARG_WITH([default_luks_format],
754 AS_HELP_STRING([--with-default-luks-format=FORMAT], [default LUKS format version (LUKS1/LUKS2) [LUKS2]]),
755 [], [with_default_luks_format=LUKS2])
757 case $with_default_luks_format in
758 LUKS1) default_luks=CRYPT_LUKS1 ;;
759 LUKS2) default_luks=CRYPT_LUKS2 ;;
760 *) AC_MSG_ERROR([Unknown default LUKS format. Use LUKS1 or LUKS2 only.]) ;;
762 AC_DEFINE_UNQUOTED([DEFAULT_LUKS_FORMAT], [$default_luks], [default LUKS format version])
764 dnl ==========================================================================
766 AC_CONFIG_FILES([ Makefile
769 scripts/cryptsetup.conf