Add optional libpwquality support for new LUKS passwords.
[platform/upstream/cryptsetup.git] / configure.in
1 AC_PREREQ([2.67])
2 AC_INIT([cryptsetup],[1.6.0-git])
3
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"
9
10 AC_CONFIG_SRCDIR(src/cryptsetup.c)
11 AC_CONFIG_MACRO_DIR([m4])
12
13 AC_CONFIG_HEADERS([config.h:config.h.in])
14 AM_INIT_AUTOMAKE(dist-bzip2)
15
16 if test "x$prefix" = "xNONE"; then
17         sysconfdir=/etc
18 fi
19 AC_PREFIX_DEFAULT(/usr)
20
21 AC_CANONICAL_HOST
22 AC_USE_SYSTEM_EXTENSIONS
23 AC_PROG_CC
24 AM_PROG_CC_C_O
25 AC_PROG_CPP
26 AC_PROG_INSTALL
27 AC_PROG_MAKE_SET
28 AC_ENABLE_STATIC(no)
29 LT_INIT
30
31 AC_HEADER_DIRENT
32 AC_HEADER_STDC
33 AC_CHECK_HEADERS(fcntl.h malloc.h inttypes.h sys/ioctl.h sys/mman.h \
34         ctype.h unistd.h locale.h)
35
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.])])
38
39 saved_LIBS=$LIBS
40 AC_CHECK_LIB(uuid, uuid_clear, ,[AC_MSG_ERROR([You need the uuid library.])])
41 AC_SUBST(UUID_LIBS, $LIBS)
42 LIBS=$saved_LIBS
43
44 AC_CHECK_FUNCS([posix_memalign])
45
46 AC_C_CONST
47 AC_C_BIGENDIAN
48 AC_TYPE_OFF_T
49 AC_SYS_LARGEFILE
50
51 AC_PROG_GCC_TRADITIONAL
52
53 dnl ==========================================================================
54
55 AM_GNU_GETTEXT([external],[need-ngettext])
56 AM_GNU_GETTEXT_VERSION([0.15])
57
58 dnl ==========================================================================
59
60 saved_LIBS=$LIBS
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)
64 LIBS=$saved_LIBS
65
66 dnl ==========================================================================
67 dnl FIPS extensions
68 AC_ARG_ENABLE([fips], AS_HELP_STRING([--enable-fips],[enable FIPS mode restrictions]),
69 [with_fips=$enableval],
70 [with_fips=no])
71
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])
76
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.])
79         fi
80
81         saved_LIBS=$LIBS
82         AC_CHECK_LIB(fipscheck, FIPSCHECK_verify, ,[AC_MSG_ERROR([You need the fipscheck library.])])
83         AC_SUBST(FIPSCHECK_LIBS, $LIBS)
84         LIBS=$saved_LIBS
85
86 fi
87
88 AC_DEFUN([NO_FIPS], [
89         if test "x$with_fips" = "xyes"; then
90                 AC_MSG_ERROR([This option is not compatible with FIPS.])
91         fi
92 ])
93
94 dnl ==========================================================================
95 dnl pwquality library (cryptsetup CLI only)
96 AC_ARG_ENABLE([pwquality], AS_HELP_STRING([--enable-pwquality],[enable password quality checking]),
97 [with_pwquality=$enableval],
98 [with_pwquality=no])
99
100 if test "x$with_pwquality" = "xyes"; then
101         AC_DEFINE(ENABLE_PWQUALITY, 1, [Enable password quality checking])
102         PKG_CHECK_MODULES([PWQUALITY], [pwquality >= 1.0.0],,
103                 AC_MSG_ERROR([You need pwquality library.]))
104
105         PWQUALITY_STATIC_LIBS=$PWQUALITY_LIBS
106 fi
107
108 dnl ==========================================================================
109 dnl Crypto backend functions
110
111 AC_DEFUN([CONFIGURE_GCRYPT], [
112         if test "x$with_fips" = "xyes"; then
113                 GCRYPT_REQ_VERSION=1.4.5
114         else
115                 GCRYPT_REQ_VERSION=1.1.42
116         fi
117         AM_PATH_LIBGCRYPT($GCRYPT_REQ_VERSION,,[AC_MSG_ERROR([You need the gcrypt library.])])
118
119         if test x$enable_static_cryptsetup = xyes; then
120                 saved_LIBS=$LIBS
121                 LIBS="$saved_LIBS $LIBGCRYPT_LIBS -static"
122                 AC_CHECK_LIB(gcrypt, gcry_check_version,,
123                         AC_MSG_ERROR([Cannot find static gcrypt library.]),
124                         [-lgpg-error])
125                 LIBGCRYPT_STATIC_LIBS="$LIBGCRYPT_LIBS -lgpg-error"
126                 LIBS=$saved_LIBS
127         fi
128
129         CRYPTO_CFLAGS=$LIBGCRYPT_CFLAGS
130         CRYPTO_LIBS=$LIBGCRYPT_LIBS
131         CRYPTO_STATIC_LIBS=$LIBGCRYPT_STATIC_LIBS
132
133         AC_DEFINE_UNQUOTED(GCRYPT_REQ_VERSION, ["$GCRYPT_REQ_VERSION"], [Requested gcrypt version])
134 ])
135
136 AC_DEFUN([CONFIGURE_OPENSSL], [
137         PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8],,
138                 AC_MSG_ERROR([You need openssl library.]))
139         CRYPTO_CFLAGS=$OPENSSL_CFLAGS
140         CRYPTO_LIBS=$OPENSSL_LIBS
141
142         if test x$enable_static_cryptsetup = xyes; then
143                 saved_PKG_CONFIG=$PKG_CONFIG
144                 PKG_CONFIG="$PKG_CONFIG --static"
145                 PKG_CHECK_MODULES([OPENSSL], [openssl])
146                 CRYPTO_STATIC_LIBS=$OPENSSL_LIBS
147                 PKG_CONFIG=$saved_PKG_CONFIG
148         fi
149         NO_FIPS([])
150 ])
151
152 AC_DEFUN([CONFIGURE_NSS], [
153         if test x$enable_static_cryptsetup = xyes; then
154                 AC_MSG_ERROR([Static build of cryptsetup is not supported with NSS.])
155         fi
156
157         AC_MSG_WARN([NSS backend does NOT provide backward compatibility (missing ripemd160 hash).])
158
159         PKG_CHECK_MODULES([NSS], [nss],,
160                 AC_MSG_ERROR([You need nss library.]))
161
162         saved_CFLAGS=$CFLAGS
163         CFLAGS="$CFLAGS $NSS_CFLAGS"
164         AC_CHECK_DECLS([NSS_GetVersion], [], [], [#include <nss.h>])
165         CFLAGS=$saved_CFLAGS
166
167         CRYPTO_CFLAGS=$NSS_CFLAGS
168         CRYPTO_LIBS=$NSS_LIBS
169         NO_FIPS([])
170 ])
171
172 AC_DEFUN([CONFIGURE_KERNEL], [
173         AC_CHECK_HEADERS(linux/if_alg.h,,
174                 [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])])
175 #       AC_CHECK_DECLS([AF_ALG],,
176 #               [AC_MSG_ERROR([You need Linux kernel with userspace crypto interface.])],
177 #               [#include <sys/socket.h>])
178         NO_FIPS([])
179 ])
180
181 AC_DEFUN([CONFIGURE_NETTLE], [
182         AC_CHECK_HEADERS(nettle/sha.h,,
183                 [AC_MSG_ERROR([You need Nettle cryptographic library.])])
184
185         saved_LIBS=$LIBS
186         AC_CHECK_LIB(nettle, nettle_ripemd160_init,,
187                 [AC_MSG_ERROR([You need Nettle library version 2.4 or more recent.])])
188         CRYPTO_LIBS=$LIBS
189         LIBS=$saved_LIBS
190
191         CRYPTO_STATIC_LIBS=$CRYPTO_LIBS
192         NO_FIPS([])
193 ])
194
195 dnl ==========================================================================
196 saved_LIBS=$LIBS
197
198 AC_ARG_ENABLE([static-cryptsetup],
199         AS_HELP_STRING([--enable-static-cryptsetup],
200         [enable build of static cryptsetup binary]))
201 if test x$enable_static_cryptsetup = xyes; then
202         if test x$enable_static = xno; then
203                 AC_MSG_WARN([Requested static cryptsetup build, enabling static library.])
204                 enable_static=yes
205         fi
206 fi
207 AM_CONDITIONAL(STATIC_TOOLS, test x$enable_static_cryptsetup = xyes)
208
209 AC_ARG_ENABLE(veritysetup,
210         AS_HELP_STRING([--disable-veritysetup],
211         [disable veritysetup support]),[], [enable_veritysetup=yes])
212 AM_CONDITIONAL(VERITYSETUP, test x$enable_veritysetup = xyes)
213
214 AC_ARG_ENABLE([cryptsetup-reencrypt],
215         AS_HELP_STRING([--enable-cryptsetup-reencrypt],
216         [enable cryptsetup-reencrypt tool]))
217 AM_CONDITIONAL(REENCRYPT, test x$enable_cryptsetup_reencrypt = xyes)
218
219 AC_ARG_ENABLE(selinux,
220         AS_HELP_STRING([--disable-selinux],
221         [disable selinux support [default=auto]]),[], [])
222
223 AC_ARG_ENABLE([udev],
224         AS_HELP_STRING([--disable-udev],
225         [disable udev support]),[], enable_udev=yes)
226
227 dnl Try to use pkg-config for devmapper, but fallback to old detection
228 PKG_CHECK_MODULES([DEVMAPPER], [devmapper >= 1.02.03],, [
229         AC_CHECK_LIB(devmapper, dm_task_set_name,,
230                 [AC_MSG_ERROR([You need the device-mapper library.])])
231         AC_CHECK_LIB(devmapper, dm_task_set_message,,
232                 [AC_MSG_ERROR([The device-mapper library on your system is too old.])])
233         DEVMAPPER_LIBS=$LIBS
234 ])
235 LIBS=$saved_LIBS
236
237 LIBS="$LIBS $DEVMAPPER_LIBS"
238 AC_CHECK_DECLS([dm_task_secure_data], [], [], [#include <libdevmapper.h>])
239 AC_CHECK_DECLS([dm_task_retry_remove], [], [], [#include <libdevmapper.h>])
240 AC_CHECK_DECLS([DM_UDEV_DISABLE_DISK_RULES_FLAG], [have_cookie=yes], [have_cookie=no], [#include <libdevmapper.h>])
241 if test "x$enable_udev" = xyes; then
242         if test "x$have_cookie" = xno; then
243                 AC_MSG_WARN([The device-mapper library on your system has no udev support, udev support disabled.])
244         else
245                 AC_DEFINE(USE_UDEV, 1, [Try to use udev synchronisation?])
246         fi
247 fi
248 LIBS=$saved_LIBS
249
250 dnl Crypto backend configuration.
251 AC_ARG_WITH([crypto_backend],
252         AS_HELP_STRING([--with-crypto_backend=BACKEND], [crypto backend (gcrypt/openssl/nss/kernel/nettle) [gcrypt]]),
253         [], with_crypto_backend=gcrypt
254 )
255 case $with_crypto_backend in
256         gcrypt)  CONFIGURE_GCRYPT([]) ;;
257         openssl) CONFIGURE_OPENSSL([]) ;;
258         nss)     CONFIGURE_NSS([]) ;;
259         kernel)  CONFIGURE_KERNEL([]) ;;
260         nettle)  CONFIGURE_NETTLE([]) ;;
261         *) AC_MSG_ERROR([Unknown crypto backend.]) ;;
262 esac
263 AM_CONDITIONAL(CRYPTO_BACKEND_GCRYPT,  test $with_crypto_backend = gcrypt)
264 AM_CONDITIONAL(CRYPTO_BACKEND_OPENSSL, test $with_crypto_backend = openssl)
265 AM_CONDITIONAL(CRYPTO_BACKEND_NSS,     test $with_crypto_backend = nss)
266 AM_CONDITIONAL(CRYPTO_BACKEND_KERNEL,  test $with_crypto_backend = kernel)
267 AM_CONDITIONAL(CRYPTO_BACKEND_NETTLE,  test $with_crypto_backend = nettle)
268
269 dnl Magic for cryptsetup.static build.
270 if test x$enable_static_cryptsetup = xyes; then
271         saved_PKG_CONFIG=$PKG_CONFIG
272         PKG_CONFIG="$PKG_CONFIG --static"
273
274         LIBS="$saved_LIBS -static"
275         AC_CHECK_LIB(popt, poptGetContext,,
276                 AC_MSG_ERROR([Cannot find static popt library.]))
277
278         dnl Try to detect needed device-mapper static libraries, try pkg-config first.
279         LIBS="$saved_LIBS -static"
280         PKG_CHECK_MODULES([DEVMAPPER_STATIC], [devmapper >= 1.02.27],,[
281                 DEVMAPPER_STATIC_LIBS=$DEVMAPPER_LIBS
282                 if test "x$enable_selinux" != xno; then
283                         AC_CHECK_LIB(sepol, sepol_bool_set)
284                         AC_CHECK_LIB(selinux, is_selinux_enabled)
285                         DEVMAPPER_STATIC_LIBS="$DEVMAPPER_STATIC_LIBS $LIBS"
286                 fi
287         ])
288         LIBS="$saved_LIBS $DEVMAPPER_STATIC_LIBS"
289         AC_CHECK_LIB(devmapper, dm_task_set_uuid,,
290                 AC_MSG_ERROR([Cannot link with static device-mapper library.]))
291
292         dnl Try to detect uuid static library.
293         LIBS="$saved_LIBS -static"
294         AC_CHECK_LIB(uuid, uuid_generate,,
295                 AC_MSG_ERROR([Cannot find static uuid library.]))
296
297         LIBS=$saved_LIBS
298         PKG_CONFIG=$saved_PKG_CONFIG
299 fi
300
301 AC_SUBST([DEVMAPPER_LIBS])
302 AC_SUBST([DEVMAPPER_STATIC_LIBS])
303
304 AC_SUBST([PWQUALITY_LIBS])
305 AC_SUBST([PWQUALITY_STATIC_LIBS])
306
307 AC_SUBST([CRYPTO_CFLAGS])
308 AC_SUBST([CRYPTO_LIBS])
309 AC_SUBST([CRYPTO_STATIC_LIBS])
310
311 AC_SUBST([LIBCRYPTSETUP_VERSION])
312 AC_SUBST([LIBCRYPTSETUP_VERSION_INFO])
313 AC_SUBST([LIBCRYPTSETUP_VERSION_FIPS])
314
315 dnl ==========================================================================
316 AC_ARG_ENABLE([dev-random], AS_HELP_STRING([--enable-dev-random],
317 [use blocking /dev/random by default for key generator (otherwise use /dev/urandom)]),
318 [default_rng=/dev/random], [default_rng=/dev/urandom])
319 AC_DEFINE_UNQUOTED(DEFAULT_RNG, ["$default_rng"], [default RNG type for key generator])
320
321 dnl ==========================================================================
322 AC_DEFUN([CS_DEFINE],
323         [AC_DEFINE_UNQUOTED(DEFAULT_[]m4_translit([$1], [-a-z], [_A-Z]), [$2], [$3])
324 ])
325
326 AC_DEFUN([CS_STR_WITH], [AC_ARG_WITH([$1],
327         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
328         [CS_DEFINE([$1], ["$withval"], [$2])],
329         [CS_DEFINE([$1], ["$3"], [$2])]
330 )])
331
332 AC_DEFUN([CS_NUM_WITH], [AC_ARG_WITH([$1],
333         [AS_HELP_STRING(--with-[$1], [default $2 [$3]])],
334         [CS_DEFINE([$1], [$withval], [$2])],
335         [CS_DEFINE([$1], [$3], [$2])]
336 )])
337
338 dnl ==========================================================================
339 dnl Python bindings
340 AC_ARG_ENABLE([python], AS_HELP_STRING([--enable-python],[enable Python bindings]),
341 [with_python=$enableval],
342 [with_python=no])
343
344 if test "x$with_python" = "xyes"; then
345         AM_PATH_PYTHON([2.4])
346
347         if ! test -x "$PYTHON-config" ; then
348             AC_MSG_ERROR([Cannot find python development packages to build bindings])
349         fi
350
351         PYTHON_INCLUDES=$($PYTHON-config --includes)
352         AC_SUBST(PYTHON_INCLUDES)
353 fi
354 AM_CONDITIONAL([PYTHON_CRYPTSETUP], [test "x$with_python" = "xyes"])
355
356 dnl ==========================================================================
357 CS_STR_WITH([plain-hash],   [password hashing function for plain mode], [ripemd160])
358 CS_STR_WITH([plain-cipher], [cipher for plain mode], [aes])
359 CS_STR_WITH([plain-mode],   [cipher mode for plain mode], [cbc-essiv:sha256])
360 CS_NUM_WITH([plain-keybits],[key length in bits for plain mode], [256])
361
362 CS_STR_WITH([luks1-hash],   [hash function for LUKS1 header], [sha1])
363 CS_STR_WITH([luks1-cipher], [cipher for LUKS1], [aes])
364 CS_STR_WITH([luks1-mode],   [cipher mode for LUKS1], [cbc-essiv:sha256])
365 CS_NUM_WITH([luks1-keybits],[key length in bits for LUKS1], [256])
366 CS_NUM_WITH([luks1-iter-time],[PBKDF2 iteration time for LUKS1 (in ms)], [1000])
367
368 CS_STR_WITH([loopaes-cipher], [cipher for loop-AES mode], [aes])
369 CS_NUM_WITH([loopaes-keybits],[key length in bits for loop-AES mode], [256])
370
371 CS_NUM_WITH([keyfile-size-maxkb],[maximum keyfile size (in KiB)], [8192])
372 CS_NUM_WITH([passphrase-size-max],[maximum keyfile size (in characters)], [512])
373
374 CS_STR_WITH([verity-hash],       [hash function for verity mode], [sha256])
375 CS_NUM_WITH([verity-data-block], [data block size for verity mode], [4096])
376 CS_NUM_WITH([verity-hash-block], [hash block size for verity mode], [4096])
377 CS_NUM_WITH([verity-salt-size],  [salt size for verity mode], [32])
378
379 dnl ==========================================================================
380
381 AC_CONFIG_FILES([ Makefile
382 lib/Makefile
383 lib/libcryptsetup.pc
384 lib/crypto_backend/Makefile
385 lib/luks1/Makefile
386 lib/loopaes/Makefile
387 lib/verity/Makefile
388 lib/tcrypt/Makefile
389 src/Makefile
390 po/Makefile.in
391 man/Makefile
392 tests/Makefile
393 python/Makefile
394 ])
395 AC_OUTPUT