2 AC_INIT([cryptsetup],[1.6.0-git])
4 dnl library version from <major>.<minor>.<release>[-<suffix>]
5 LIBCRYPTSETUP_VERSION=$(echo $PACKAGE_VERSION | cut -f1 -d-)
6 LIBCRYPTSETUP_VERSION_INFO=8:0:4
7 dnl library file name for FIPS selfcheck
8 LIBCRYPTSETUP_VERSION_FIPS="libcryptsetup.so.4"
10 AC_CONFIG_SRCDIR(src/cryptsetup.c)
11 AC_CONFIG_MACRO_DIR([m4])
13 AC_CONFIG_HEADERS([config.h:config.h.in])
14 AM_INIT_AUTOMAKE(dist-bzip2)
16 if test "x$prefix" = "xNONE"; then
19 AC_PREFIX_DEFAULT(/usr)
22 AC_USE_SYSTEM_EXTENSIONS
33 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
34 ctype.h unistd.h locale.h)
36 AC_CHECK_HEADERS(uuid/uuid.h,,[AC_MSG_ERROR([You need the uuid library.])])
37 AC_CHECK_HEADER(libdevmapper.h,,[AC_MSG_ERROR([You need the device-mapper library.])])
40 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
41 AC_SUBST(UUID_LIBS, $LIBS)
44 AC_CHECK_FUNCS([posix_memalign])
51 AC_PROG_GCC_TRADITIONAL
53 dnl ==========================================================================
55 AM_GNU_GETTEXT([external],[need-ngettext])
56 AM_GNU_GETTEXT_VERSION([0.15])
58 dnl ==========================================================================
61 AC_CHECK_LIB(popt, poptConfigFileToString,,
62 [AC_MSG_ERROR([You need popt 1.7 or newer to compile.])])
63 AC_SUBST(POPT_LIBS, $LIBS)
66 dnl ==========================================================================
68 AC_ARG_ENABLE([fips], AS_HELP_STRING([--enable-fips],[enable FIPS mode restrictions]),
69 [with_fips=$enableval],
72 if test "x$with_fips" = "xyes"; then
73 AC_DEFINE(ENABLE_FIPS, 1, [Enable FIPS mode restrictions])
74 AC_DEFINE_UNQUOTED(LIBCRYPTSETUP_VERSION_FIPS, ["$LIBCRYPTSETUP_VERSION_FIPS"],
75 [library file name for FIPS selfcheck])
77 if test "x$enable_static" = "xyes" -o "x$enable_static_cryptsetup" = "xyes" ; then
78 AC_MSG_ERROR([Static build is not compatible with FIPS.])
82 AC_CHECK_LIB(fipscheck, FIPSCHECK_verify, ,[AC_MSG_ERROR([You need the fipscheck library.])])
83 AC_SUBST(FIPSCHECK_LIBS, $LIBS)
89 if test "x$with_fips" = "xyes"; then
90 AC_MSG_ERROR([This option is not compatible with FIPS.])
94 dnl ==========================================================================
95 dnl Crypto backend functions
97 AC_DEFUN([CONFIGURE_GCRYPT], [
98 if test "x$with_fips" = "xyes"; then
99 GCRYPT_REQ_VERSION=1.4.5
101 GCRYPT_REQ_VERSION=1.1.42
103 AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])
105 if test x$enable_static_cryptsetup = xyes; then
107 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
108 AC_CHECK_LIB(gcrypt, gcry_check_version,,
109 AC_MSG_ERROR([Cannot find static gcrypt library.]),
111 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
115 CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
116 CRYPTO_LIBS=$LIBGCRYPT_LIBS
117 CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
119 AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
122 AC_DEFUN([CONFIGURE_OPENSSL], [
123 PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
124 AC_MSG_ERROR([You need openssl library.]))
125 CRYPTO_CFLAGS=$OPENSSL_CFLAGS
126 CRYPTO_LIBS=$OPENSSL_LIBS
128 if test x$enable_static_cryptsetup = xyes; then
129 saved_PKG_CONFIG=$PKG_CONFIG
130 PKG_CONFIG="$PKG_CONFIG --static"
131 PKG_CHECK_MODULES([OPENSSL], [openssl])
132 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
133 PKG_CONFIG=$saved_PKG_CONFIG
138 AC_DEFUN([CONFIGURE_NSS], [
139 if test x$enable_static_cryptsetup = xyes; then
140 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
143 AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
145 PKG_CHECK_MODULES([NSS], [nss],,
146 AC_MSG_ERROR([You need nss library.]))
149 CFLAGS="$CFLAGS $NSS_CFLAGS"
150 AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
153 CRYPTO_CFLAGS=$NSS_CFLAGS
154 CRYPTO_LIBS=$NSS_LIBS
158 AC_DEFUN([CONFIGURE_KERNEL], [
159 AC_CHECK_HEADERS(linux/if_alg.h,,
160 [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])])
161 # AC_CHECK_DECLS([AF_ALG],,
162 # [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
163 # [#include <sys/socket.h>])
167 AC_DEFUN([CONFIGURE_NETTLE], [
168 AC_CHECK_HEADERS(nettle/sha.h,,
169 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
172 AC_CHECK_LIB(nettle, nettle_ripemd160_init,,
173 [AC_MSG_ERROR([You need Nettle library version 2.4 or more recent.])])
177 CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
181 dnl ==========================================================================
184 AC_ARG_ENABLE([static-cryptsetup],
185 AS_HELP_STRING([--enable-static-cryptsetup],
186 [enable build of static cryptsetup binary]))
187 if test x$enable_static_cryptsetup = xyes; then
188 if test x$enable_static = xno; then
189 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
193 AM_CONDITIONAL(STATIC_TOOLS, test x$enable_static_cryptsetup = xyes)
195 AC_ARG_ENABLE(veritysetup,
196 AS_HELP_STRING([--disable-veritysetup],
197 [disable veritysetup support]),[], [enable_veritysetup=yes])
198 AM_CONDITIONAL(VERITYSETUP, test x$enable_veritysetup = xyes)
200 AC_ARG_ENABLE([cryptsetup-reencrypt],
201 AS_HELP_STRING([--enable-cryptsetup-reencrypt],
202 [enable cryptsetup-reencrypt tool]))
203 AM_CONDITIONAL(REENCRYPT, test x$enable_cryptsetup_reencrypt = xyes)
205 AC_ARG_ENABLE(selinux,
206 AS_HELP_STRING([--disable-selinux],
207 [disable selinux support [default=auto]]),[], [])
209 AC_ARG_ENABLE([udev],
210 AS_HELP_STRING([--disable-udev],
211 [disable udev support]),[], enable_udev=yes)
213 dnl Try to use pkg-config for devmapper, but fallback to old detection
214 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
215 AC_CHECK_LIB(devmapper, dm_task_set_name,,
216 [AC_MSG_ERROR([You need the device-mapper library.])])
217 AC_CHECK_LIB(devmapper, dm_task_set_message,,
218 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
223 LIBS="$LIBS $DEVMAPPER_LIBS"
224 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
225 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
226 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
227 if test "x$enable_udev" = xyes; then
228 if test "x$have_cookie" = xno; then
229 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
231 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
236 dnl Crypto backend configuration.
237 AC_ARG_WITH([crypto_backend],
238 AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
239 [], with_crypto_backend=gcrypt
241 case $with_crypto_backend in
242 gcrypt) CONFIGURE_GCRYPT([]) ;;
243 openssl) CONFIGURE_OPENSSL([]) ;;
244 nss) CONFIGURE_NSS([]) ;;
245 kernel) CONFIGURE_KERNEL([]) ;;
246 nettle) CONFIGURE_NETTLE([]) ;;
247 *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
249 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT, test $with_crypto_backend = gcrypt)
250 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
251 AM_CONDITIONAL(CRYPTO_BACKEND_NSS, test $with_crypto_backend = nss)
252 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL, test $with_crypto_backend = kernel)
253 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE, test $with_crypto_backend = nettle)
255 dnl Magic for cryptsetup.static build.
256 if test x$enable_static_cryptsetup = xyes; then
257 saved_PKG_CONFIG=$PKG_CONFIG
258 PKG_CONFIG="$PKG_CONFIG --static"
260 LIBS="$saved_LIBS -static"
261 AC_CHECK_LIB(popt, poptGetContext,,
262 AC_MSG_ERROR([Cannot find static popt library.]))
264 dnl Try to detect needed device-mapper static libraries, try pkg-config first.
265 LIBS="$saved_LIBS -static"
266 PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
267 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
268 if test "x$enable_selinux" != xno; then
269 AC_CHECK_LIB(sepol, sepol_bool_set)
270 AC_CHECK_LIB(selinux, is_selinux_enabled)
271 DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
274 LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
275 AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
276 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
278 dnl Try to detect uuid static library.
279 LIBS="$saved_LIBS -static"
280 AC_CHECK_LIB(uuid, uuid_generate,,
281 AC_MSG_ERROR([Cannot find static uuid library.]))
284 PKG_CONFIG=$saved_PKG_CONFIG
287 AC_SUBST([DEVMAPPER_LIBS])
288 AC_SUBST([DEVMAPPER_STATIC_LIBS])
290 AC_SUBST([CRYPTO_CFLAGS])
291 AC_SUBST([CRYPTO_LIBS])
292 AC_SUBST([CRYPTO_STATIC_LIBS])
294 AC_SUBST([LIBCRYPTSETUP_VERSION])
295 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
296 AC_SUBST([LIBCRYPTSETUP_VERSION_FIPS])
298 dnl ==========================================================================
299 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
300 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
301 [default_rng=/dev/random], [default_rng=/dev/urandom])
302 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
304 dnl ==========================================================================
305 AC_DEFUN([CS_DEFINE],
306 [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
309 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
310 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
311 [CS_DEFINE([$1], ["$withval"], [$2])],
312 [CS_DEFINE([$1], ["$3"], [$2])]
315 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
316 [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
317 [CS_DEFINE([$1], [$withval], [$2])],
318 [CS_DEFINE([$1], [$3], [$2])]
321 dnl ==========================================================================
323 AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
324 [with_python=$enableval],
327 if test "x$with_python" = "xyes"; then
328 AM_PATH_PYTHON([2.4])
330 if ! test -x "$PYTHON-config" ; then
331 AC_MSG_ERROR([Cannot find python development packages to build bindings])
334 PYTHON_INCLUDES=$($PYTHON-config --includes)
335 AC_SUBST(PYTHON_INCLUDES)
337 AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])
339 dnl ==========================================================================
340 CS_STR_WITH([plain-hash], [password hashing function for plain mode], [ripemd160])
341 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
342 CS_STR_WITH([plain-mode], [cipher mode for plain mode], [cbc-essiv:sha256])
343 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
345 CS_STR_WITH([luks1-hash], [hash function for LUKS1 header], [sha1])
346 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
347 CS_STR_WITH([luks1-mode], [cipher mode for LUKS1], [cbc-essiv:sha256])
348 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
349 CS_NUM_WITH([luks1-iter-time],[PBKDF2 iteration time for LUKS1 (in ms)], [1000])
351 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
352 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
354 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
355 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in characters)], [512])
357 CS_STR_WITH([verity-hash], [hash function for verity mode], [sha256])
358 CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
359 CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
360 CS_NUM_WITH([verity-salt-size], [salt size for verity mode], [32])
362 dnl ==========================================================================
364 AC_CONFIG_FILES([ Makefile
367 lib/crypto_backend/Makefile