repart: add EncryptKDF= option for LUKS2 partitions

systemd-repart currently creates LUKS2 encrypted partitions using
libcryptsetup's default KDF (Argon2id), which requires ~1GB of memory
during key derivation. This is too much for memory-constrained
environments such as kdump with limited crashkernel memory, where
luksOpen fails due to insufficient memory.

Add an EncryptKDF= option to repart.d partition definitions that allows
selecting the KDF type. Supported values are:

- "argon2id" — Argon2id with libcryptsetup-benchmarked parameters
- "pbkdf2"  — PBKDF2 with libcryptsetup-benchmarked parameters
- "minimal" — PBKDF2 with SHA-512, 1000 iterations, no benchmarking,
  matching the existing cryptsetup_set_minimal_pbkdf() behaviour used
  for TPM2-sealed keys

When not specified, the libcryptsetup default (argon2id) is used,
preserving existing behaviour.

The KDF type is applied via sym_crypt_set_pbkdf_type() after
sym_crypt_format() and before any keyslots are added.
This commit is contained in:
Nandakumar Raghavan
2026-04-18 11:03:52 +01:00
committed by Luca Boccassi
parent 2a6e40c2f5
commit fa6eb2e016
2 changed files with 71 additions and 0 deletions
+24
View File
@@ -695,6 +695,30 @@
<xi:include href="version-info.xml" xpointer="v261"/></listitem>
</varlistentry>
<varlistentry>
<term><varname>EncryptKDF=</varname></term>
<listitem><para>Specifies the key derivation function (KDF) to use for LUKS2 encryption keyslots.
Takes one of <literal>argon2id</literal>, <literal>pbkdf2</literal>, or <literal>minimal</literal>.
If not specified, the default is determined by the cryptsetup library (typically
<literal>argon2id</literal>). This option has no effect if <varname>Encrypt=</varname> is
<literal>off</literal>.</para>
<para>When set to <literal>argon2id</literal> or <literal>pbkdf2</literal>, the specified KDF is
used with parameters benchmarked by the cryptsetup library. When set to <literal>minimal</literal>,
PBKDF2 is used with SHA-512, 1000 iterations, and no benchmarking — this is appropriate for
high-entropy keys (e.g. generated by a hardware key manager or sealed to a TPM) where the KDF only
needs to satisfy the LUKS2 format requirement, not strengthen a weak passphrase.</para>
<para>Note that Argon2-based KDFs may require significant memory (up to 1GB) during key derivation.
In memory-constrained environments such as kdump with limited crashkernel memory,
<literal>minimal</literal> or <literal>pbkdf2</literal> may be more appropriate. When
<varname>Encrypt=</varname> includes <literal>tpm2</literal>, the TPM2 keyslot always uses a minimal
PBKDF2 configuration regardless of this setting.</para>
<xi:include href="version-info.xml" xpointer="v261"/></listitem>
</varlistentry>
<varlistentry>
<term><varname>Verity=</varname></term>