Files
nwipe/configure.ac

93 lines
2.8 KiB
Plaintext
Raw Normal View History

2013-09-06 23:38:39 +01:00
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([nwipe],[0.39],[git@brumit.nl])
AM_INIT_AUTOMAKE(foreign subdir-objects)
2023-10-01 23:45:48 +02:00
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
AC_OUTPUT
2013-09-06 23:38:39 +01:00
AC_CONFIG_SRCDIR([src/nwipe.c])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CC
Implement high-performance AES-256-CTR PRNG via Linux kernel AF_ALG socket Problem ======= The OpenSSL-based prelimininary, not yet committed userspace PRNG in nwipe plateaued at ~250 MB/s, becoming the primary bottleneck when wiping modern NVMe or RAID volumes that sustain gigabytes per second. Solution ======== Replace the OpenSSL path with a kernel-accelerated AES-256-CTR generator that streams 16 KiB keystream blocks through the AF_ALG “ctr(aes)” skcipher: * Added aes_ctr_prng.cpp/.h • Opens a per-thread AF_ALG operation socket once (lazy init). • Builds a two-CMSG `sendmsg()` (ALG_SET_OP + ALG_SET_IV) and a single `read()` per chunk – minimal syscall overhead. • Public state (aes_ctr_state_t) intentionally remains 256 bit to preserve ABI compatibility; socket FD is kept thread-local. • Generates exactly 16 KiB per call, advancing an internal 128-bit counter. * Comprehensive English comments explain every function, the ABI rationale and the kernel interaction pattern. Performance ----------- On a Ryzen 9 7950X (VAES): • Old OpenSSL path: ~260 MB/s • New AF_ALG path : ~6.2 GB/s (≈ 24× faster, CPU-bound at ~7 % load) Safety & Compatibility ---------------------- * Falls back automatically to the kernel’s software AES if AES-NI/VAES/SVE are absent – no code changes required. * No external dependencies beyond standard linux-headers. * Optional `aes_ctr_prng_shutdown()` closes the FD, though the kernel would reclaim it on exit anyway. Testing ------- * Added unit tests for counter wraparound and deterministic output with a fixed seed (compared to OpenSSL reference vectors). * Verified multi-threaded wiping on a 4 × NVMe RAID-0 → sustained device speed, PRNG never starved the pipeline. Future work ----------- * Expose chunk size as a tunable CLI flag. * Optionally copy keystream directly into the kernel’s page cache via `splice`. Closes: #559 (Implement High-Quality Random Number Generation Using AES-CTR Mode with OpenSSL and AES-NI Support)
2025-05-25 16:28:30 -03:00
AC_PROG_CXX
2013-09-06 23:38:39 +01:00
PKG_PROG_PKG_CONFIG
# Checks for libraries.
PKG_CHECK_MODULES(
[PANEL],
[panel],
[
CFLAGS="${CFLAGS} ${PANEL_CFLAGS}"
LIBS="${LIBS} ${PANEL_LIBS}"
],
[AC_CHECK_LIB([panel], [main], [
LIBS="-lpanel $LIBS"
AC_CHECK_HEADERS(panel.h,, [
AC_CHECK_HEADERS(ncurses/panel.h, [
AC_DEFINE([PANEL_IN_SUBDIR], [ncurses/], [Look for ncurses headers in subdir])
], [AC_MSG_ERROR([ncurses panel headers not found])])
])
], [AC_MSG_ERROR([ncurses panel library not found])])]
2013-09-06 23:38:39 +01:00
)
PKG_CHECK_MODULES(
[NCURSES],
[ncurses],
[
CFLAGS="${CFLAGS} ${NCURSES_CFLAGS}"
LIBS="${LIBS} ${NCURSES_LIBS}"
],
[AC_CHECK_LIB([ncurses], [delscreen], [
LIBS="-lncurses $LIBS"
AC_CHECK_HEADERS(ncurses.h,, [
AC_CHECK_HEADERS(ncurses/ncurses.h, [
AC_DEFINE([NCURSES_IN_SUBDIR], [ncurses/], [Look for ncurses headers in subdir])
], [AC_MSG_ERROR([ncurses headers not found])])
])
], [AC_MSG_ERROR([ncurses development library not found])]
)]
)
PKG_CHECK_MODULES(
[LIBCONFIG],
[libconfig],
[
CFLAGS="${CFLAGS} ${LIBCONFIG_CFLAGS}"
LIBS="${LIBS} ${LIBCONFIG_LIBS}"
],
[AC_CHECK_LIB([libconfig], [main], [
LIBS="-llibconfig $LIBS"
AC_CHECK_HEADERS(libconfig.h,, [
AC_CHECK_HEADERS(libconfig.h, [
AC_DEFINE([LIBCONFIG_IN_SUBDIR], [libconfig/], [Look for libconfig headers in subdir])
], [AC_MSG_ERROR([libconfig headers not found])])
])
], [AC_MSG_ERROR([libconfig library not found])])]
)
2025-04-09 12:52:32 +10:00
# Libraries needed for static linking with parted
if echo "$LDFLAGS" | grep -q "static"; then
AC_CHECK_LIB([uuid], [uuid_generate], [LIBS="-luuid $LIBS"], [AC_MSG_ERROR([libuuid is required for static linking but not found])])
AC_CHECK_LIB([devmapper], [dm_task_create], [LIBS="-ldevmapper $LIBS"], [AC_MSG_ERROR([libdevmapper is required for static linking but not found])])
AC_CHECK_LIB([blkid], [blkid_new_probe], [LIBS="-lblkid $LIBS"], [AC_MSG_ERROR([libblkid is required for static linking but not found])])
2025-04-09 12:52:32 +10:00
fi
PKG_CHECK_MODULES([PARTED], [libparted])
2013-09-06 23:38:39 +01:00
AC_CHECK_LIB([pthread], [main], ,[AC_MSG_ERROR([pthread development library not found])])
# Checks for header files.
AC_CHECK_HEADERS([libconfig.h fcntl.h inttypes.h netinet/in.h stddef.h stdint.h stdlib.h string.h sys/file.h sys/ioctl.h unistd.h])
2013-09-06 23:38:39 +01:00
# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
AC_CHECK_MEMBERS([struct stat.st_blksize])
# Checks for library functions.
AC_FUNC_MALLOC
AC_CHECK_FUNCS([fdatasync memset regcomp strdup strerror])
AC_OUTPUT